for anyone that knows c++

Troncoso

VIP Member
solved

i have this code:

Code:
int main()
{
	string name1, name2, name3;
	string last1, last2, last3;
	char letter1, letter2, letter3;
	double grade1, grade2, grade3;
	double s1, s2, s3, s4, s5, s6;
	ifstream inFile;

	inFile.open("c:\\Grades.txt");
	inFile >> name1;
	cout << name1 << endl;

        return 0;
}

but when I run it nothing is displayed except a blank line. There is a string in Grades.txt but its not assigning it to name1. What could be wrong?

EDIT: solved. When ever you name a text file, don't manually type in .txt, else you get this: Grades.txt.txt. haha
 
Last edited:
Ok well you are missing } at the end if i'm not mistaken. I took it few years ago and correct me if i'm wrong. I also think you are missing something else at the end but i cant remember.... :( I dont have a compiler installed on my pc and i cant run the code to help you out...

Edit: Ok it should end like this if i'm right:

return 0;
}
 
Last edited:
haha, sorry I didn't put that in my sample code. But that is in my code. the program runs, but doesn't give me my desired results. The error has to be in the section of code I posted. I just didn't put the whole thing to avoid scrolling and reading. Thank you very much for the prompt reply. This assignment is due tonight and I need help as soon as possible.
 
I'm sorry i cant really help you with that because i need to have the compiler to do few experiments. :(
 
Back
Top