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...
multiple .cpp example
Re: multiple .cpp example
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
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.
Re: multiple .cpp example
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)
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
Who is online
Users browsing this forum: Semrush [Bot] and 1 guest