-
text output almost works
#include <stdlib.h>
#include <iostream>
#include <string>
#include <fstream>
#include <windows.h>
using namespace std;
int main()
{
ifstream fin;
string szName = "";
int health=0, gold = 0;
fin.open("Stats.txt");
if(fin.fail())
{
cout << "ERROR: Could not find .txt file!\n";
return 0;
}
cout << endl;
while(fin >> szWord)
cout << szWord;
}
I get this error C:\outputprogram.cpp(22) : error C2065: 'szWord' : undeclared identifier
how should i change it
thanks in advanced
-
you haven't defined it. add a to the top of your code somewhere.
-
I dont get this, why is everybody putting sz before the variables?
I've seen other people do this aswell.
Is it some book that tells you to do this?!?
-
>>> Is it some book that tells you to do this?!?
Browse the Microsoft documentation. It is generally known as "Hungarian Notation". It is supposed to be useful in that you can see at a glance the type of a variable by the prefix letters.
>>> why is everybody putting sz before
Everybody isn't, some do.
Frankly, I have never agreed with it, and the prefix's become so damn complicated that you spend minutes trying to work them out - I guess, however, it would come with practice.
It may have had uses in the past, but any decent IDE these days will tell you what type a variable is, offer to take you to it's definition etc.
-
why do all these damn people playing online games say 'all your base are belong to us' and why are tomatoes considered a fruit, and why we all have to ask so many questions?
-
Why do you want people to stop asking questions? :P
-
cause they gain in posts!:)