Whats wrong with my code? =(

Posts 1–14 of 14 · Page 1 of 1
Whats wrong with my code? =(
Code:
1: #include <iostream.h>
2:
3:
4: int main();
5: {
6: cout <<"Hello World!\n";
7:     return 0;
8: }
It should look like this:

Code:
#include <iostream.h>

int main()
{
    cout << "Hello World!\n";
    return 0;
}
First error is "int main();" I think it should be just "int main()" and second is you haven't put a space between "<<" and the text in parenthesis.
You have to put this right after I/Ostream:

using namespace std;

Topic Moved.
Dude. Der thanks arun. :P
Oh yeah, forgot that too! Haha.
and thanks to gkanth too
Quote Originally Posted by Gkanth
and thanks to gkanth too
u were thinking of a solution, just forgot to post it right? Cmon, thank her 4 trying in her own special way!
Dude wtf someone tell me why this doesn't work still. >.>



And calard.....her who? :P
Hello world.zipattachment deleted · 4 downloads before removal
you should put

#include <iostream>
int main()
{
cout<<"whut ever text you want";
cin.get(); //it means you press enter to close the window
}



dont worry im new too c++ too
Or you could just make a random variable and call cin...it's kinda useless, but...it works


Code:
#include <iostream.h>
using namespace std;

int main()
{

    int random;

    cout << "TEXT!!!\n";
    cin >> random; 

    return 0;

}
if you keep bumping old threads imma have to have the bant stick be shoved up your ass
I haven't bumped that many old threads.
Hey i got some problem too :
Code:
//Main.cpp
#include <iostream.h>
#include <fstream.h>
#include "test.h"



int main()
{
    write();
    return 0;
}
Code:
//test.h
#include <fstream.h>
#include <iostream.h>


fstream file;


int write()
{
    int x=0;

    file.open("G:\temp\test.txt", ios::out);
    file << "testing" << endl;
    file >> x;
    cout << x;
    file.close;
    
    return 0;
}
When i compile this i got :
Code:
3 G:\Dev-Cpp\InOut.cpp In file included from G:\Dev-Cpp\InOut.cpp 
 G:\Dev-Cpp\test.h In function `int write()': 
16 G:\Dev-Cpp\test.h statement cannot resolve address of overloaded function
How to fix it?

Ty
Posts 1–14 of 14 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?