I want to know how I can create a file in c++ to put the needed code. Also, How
ID: 3850232 • Letter: I
Question
I want to know how I can create a file in c++ to put the needed code. Also, How I can run it. I am new to the program.
Thanks
Requirements Get the "Hello, world!" program working Add a function (ShowProgramHeader as described in lecture) to print your name and class information before the "Hello, world!" message. Note: This will be required on all future assignments. The following changes should generate compiler errors/warnings. If it does, record the message; if it does not, record that. Turn this record in with your assignment. Remove the semi-colon from the output statement in main() Comment out the using namespace sted; statement. Use either a block comment or an in-line comment. Is there a difference? Comment out the thinclude kiostream (thinclude kiostream.h on older compilers) statement. Use either a block comment or an in-line comment. Is there a difference? Change the double quotes that enclose the Hello world! message to single quotes. Change the (put to operator) to on one of your output lines. Remove the starting brace from main() Remove the closing brace from main() Change cout to Cout or COUT. Change main to Main or MAIN Change the name of the function that displays your name, date, etc., from ShowProgram Header to showHeader Deliverables Program- fully documented Output neatly formatted and documented. List of errors neatly formatted If you have any questions regarding this assignment, do not hesitate to contact me. This assignment y important to those of you unfamiliar with compilers. Start working on this assignment as soon as possible.Explanation / Answer
In c++ there are few classes to read/write and to read and write both.
like, ifstream is used to read from the file.
ofstream is used to write from the file.
fstream is used for both reading and writing from the file.
your code should be like this------>
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ofstream finalFile;
finalFile.open ("file12.txt");
finalFile << "Hello World.";
finalFile.close();
return 0;
}
To run the file open develpoer command prompt.
Suppose your c++ file name is hello.cpp than
enter cl /EHsc hello.cpp this will compile your file and compiler will create .obj file
that will have compiled code and than it will run the linker to create hello.exe file which is executable programme.
Finally to run your executable file hello.exe at comand propmt, enter hello.
OUTPUT:
Hello World.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.