I am not the best programmer with c++ but I am trying to learn. I am trying to take user input and write it into a text file (without overwriting the old one) but I can’t figure out where to plugin the variable (int). Here is my code so far…
int main()
{
int i;
cout << "Please enter something: ";
cin >> i;
FILE * pFile;
pFile = fopen ("C:\\users\\grant\\desktop\\test.txt","a");
if (pFile!=NULL)
fputs ("C++ Rocks!",pFile);
fclose (pFile);
getch();
return 0;
}
Also, if there is a more effecient way of doing this, please let me know! This is just what I was able to find on the internet that worked.
I think this would do: