Jump to content

C++ Question


Recommended Posts

    if (std::strcmp(answer, "yes")) {
        std::cout<<"Please stand by while the data is being gathered and the file is being generated...\n";
        std::ofstream outfile("C:/Users/businessman332211/Desktop/test.txt");
        outfile << "This is data." << std::endl;
        outfile.close();
        system("pause");
    }

I had this figured out before, but I stepped away from C++ and I am trying to pick up where I left off.

basically I just want to generate a text file on the desktop...This isn't working even though everything i have read tells me it should

 

Another question..what happens if I want to step out of the C drive and access another drive...for example an External harddrive, or a secondary drive on the same computer?

Link to comment
https://forums.phpfreaks.com/topic/190427-c-question/
Share on other sites

Nevermind..it was me using the compare function wrong.

    if (std::strcmp(answer, "yes") == 0) {
        std::cout<<"Please stand by while the data is being gathered and the file is being generated...\n";
        std::ofstream myfile;
        myfile.open("C:/Users/businessman332211/Desktop/example.txt");
        myfile<<"This is data.";
        myfile.close();
        return 0;
    }

That is the right way.

Link to comment
https://forums.phpfreaks.com/topic/190427-c-question/#findComment-1004497
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.