Im having trouble clearing the strg variable in my code, i have tryed cout<<flush(); and <<endl but each time i run the function it concatenates the new data with the old.
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main()
{
static char str[12], strg[100];
char ismapname[] = "mapname:", ismapdisc[] = "mapdisc:";
char filename [ FILENAME_MAX ];
sprintf(filename, "%d.txt", roomnum);
ifstream file(filename );
do{
File >> str;
}
while (strcmp (str,ismapname) != 0);
do{
File >> str;
if (strcmp (str,ismapdisc) == 0) break;
strcat (strg,str);
}
while (strcmp (str,ismapname) != 0);
puts (strg);
cout<<endl<<endl;
File.close();
}