I Download your attached file but I found nothing in them except some garbage text.
Anyway
Check This code

Code:
#include <iostream>
#include <cstdlib>
#include <cctype>
#include <fstream>
#include <cstdio>
using namespace std;

int main()
{
    string str[4]={"abc","def","ghi","jkl"};
/* c++ code
    fstream f;
    f.open("abc.txt",ios::out);
    if(!f)
    {
        cout<<"Cannot Open File";
        return 0;
    }
    f<<str[2];
    f.close();
    f.open("abc.txt",ios::in);
    if(!f)
    {
        cout<<"Cannot Open File";
        return 0;
    }
    f>>str[1];
    cout<<str[1];
    f.close();
*/
// C Code
    FILE *fp;
    fp = fopen("abc.txt","w");
    if(fp==NULL)
    {
        cout<<"Cannot Open File";
        return 0;
    }
    fprintf(fp,"%s",str[2].c_str());
    fclose(fp);
	return 0;
}
For me this code works fine. I think you are using C code in c++. Maybe you are getting this warning if you are using GCC compiler
Quote:
warning: cannot pass objects of non-POD type `struct std::string' through `...'; call will abort at runtime
This error occurs because
The %s argument requires a c-styled string, but you've passed it an actual std::string object.
[/quote]
Check my above code in c++ code is working fine. Even if you are using %s then use c_str() function to convert it into const char *.



Quote:
//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?
I am not that much strong in C but amazed why you are using & in fprintf() function.

You can more read about POD in this link
http://www.fnal.gov/docs/working-gro...x/doc/POD.html
http://www.digitalfanatics.org/index...CompilerErrors

Regards