how to open file in c with extension not .txt? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 2

how to open file in c with extension not .txt?

for example i want to open

16th Dec 2018, 3:17 AM
3 Antworten
+ 2
I don'tknow in c , but in c++ we use the fstream library. #include <fstream> std::string str; // for reading ifstram file("file.ABC"); file >> str; // To write ofstream file2(""); file2 << "stuff"; There are other methods as well
16th Dec 2018, 5:43 AM
+ 2
Other method may be using strinstreams #include <sstream> stringstream ss( file ); // Read a word ss >> str; // Read many words ss >> str >> str2 >> ... // Read full line getline(ss, str);
16th Dec 2018, 5:51 AM
+ 1
In C you specify the file name and extension with an optional directory path. For example, to open "\home\user\directory\" you would use "\\home\\directory\\". Any spaces or special characters need to be escaped like \" to include a " in the file name. There is nothing special about the extension, except that some programs expect and default to a specific extension if one is not specified. End the file name with a . if you don't want the program to append the default extension when you don't supply one.
1st Feb 2019, 4:52 AM
Roger Greenlaw