multiple .cpp example

Got something cool to help make the toolchains better? Post it here.
Post Reply
opearn
Posts: 23
Joined: Tue Feb 17, 2009 11:29 am

multiple .cpp example

Post by opearn » Sun Feb 22, 2009 10:40 am

here is my example,
it shows you how to initialize new commands e.g in my main.cpp i've written
hello();
to write hello world on the screen...
it is extremely useful when making a long program.

heres the link

btw sorry about double post... its relevent to both categories...

susanspy
Posts: 1
Joined: Thu Mar 19, 2009 1:52 pm

Re: multiple .cpp example

Post by susanspy » Thu Mar 19, 2009 6:41 pm

hello all,

my name is susan, i am newbie here, in this program something is wrong but i dont know what is wrong?

#include<iostream.h>
main()
{
int num;
cout<<" Enter a number :";
cin>> num;

cout << Number "<< num;

}

}

please help



cheers!!!!!!!!!!


keyword software~keyword tool
search keyword~track keyword
Last edited by susanspy on Fri Apr 03, 2009 11:25 am, edited 1 time in total.

weirdfox
Posts: 29
Joined: Thu Feb 19, 2009 8:45 am
Location: Montreal, Canada
Contact:

Re: multiple .cpp example

Post by weirdfox » Fri Mar 20, 2009 12:23 am

Fast analysis of the code:
  • The main has no type (and no return).
  • There is too many closing bracket.
  • The good header to include (in standard C++) is not <iostream.h>, but <iosteam> (the .h version, if it's still there, should be tag as deprecated by the compiler)
  • The functions cin and cout require to have a prefix "std::" as they are in the std namespace ( ou simply add "using namespace std;" before your main)
Here's someting that would compile :

Code: Select all

#include <iostream>
int main()
{
    int num;
    std::cout << " Enter a number   :";
    std::cin >> num;

    std::cout << "Number " << num;
    return 0;
}
try, crash, debug and learn :)

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests