Hi, I had a problem in printing a String class string to a file where I had declared:

string str1[10], str2[10];

And in str1[6] and str2[6] has the values which I wanna store the values by writing them to a txt file using the format:

// write to apsignal.txt
newfile= fopen("apsignal.txt","w");
if (newfile==NULL)
{
cout<<"Error opening apsignal.txt";
fclose(newfile);
return -1;
}


//Print to file with the signal strengths and corresponding clientIDs.
fprintf(newfile,"1" " %s" " %s", &str1[6], &str2[6] );
fclose(newfile);

however, it seems like it cannot print out the values in the txt file as it is a string class? So I was wondering if anyone can give me other alternatives to write the values into this text file?

Thanks! I had attached the relevant files and pls take a look at the apsignal.txt and you will know what I mean. Thanks for any help!
Attached Files
File Type: txt ap1.txt (176 Bytes, 5 views)
File Type: txt ap2.txt (176 Bytes, 3 views)
File Type: txt apsignal.txt (17 Bytes, 4 views)
File Type: txt snmptimer code.txt (3.1 KB, 4 views)