Question:
C++ Question. 10 points for most helpfull answer?
Bond Man
2009-06-08 10:08:41 UTC
1: Is there away to make my program, start another program?

2: Is there away to hide the command prompt? I am not doing anything GUI, I just want something to run in the background.

3: How do you read numbers from a txt file?

4: how do you copy a txt document adn paste it someplace else?

5: How do you delete a text document?

Thanks in advance.
Four answers:
2009-06-08 12:28:21 UTC
1: Is there away to make my program, start another program?

Try system, eg. system("pause");



2: Is there away to hide the command prompt? I am not doing anything GUI, I just want something to run in the background.



If you are create a console application then no, not directly. Best you can do is to create a link for starting the application and set it to start minimized.



3: How do you read numbers from a txt file?

YOu have to use fread (http://www.cplusplus.com/reference/clibrary/cstdio/fread/) to read the data into a string variable and then handle the conversion. I think ATOI would do that for you.



4: how do you copy a txt document adn paste it someplace else?

bool copyFile (const char SRC[], const char DEST[])

{

std::ifstream src; // the source file

std::ofstream dest; // the destination file



src.open (SRC, std::ios::binary); // open in binary to prevent jargon at the end of the buffer

dest.open (DEST, std::ios::binary); // same again, binary

if (!src.is_open() || !dest.is_open())

return false; // could not be copied



dest << src.rdbuf (); // copy the content

dest.close (); // close destination file

src.close (); // close source file



return true; // file copied successfully

}





5: How do you delete a text document?

Use the remove function (http://www.cplusplus.com/reference/clibrary/cstdio/remove/)
Roharme
2009-06-08 10:33:21 UTC
http://infosyndrome.blogspot.com



1: Is there away to make my program, start another program?

Absolutely Not Possible.



2: Is there away to hide the command prompt? I am not doing anything GUI, I just want something to run in the background.



NO. Better try visual C++ and hide it with your GUI



3: How do you read numbers from a txt file?

filepointer.get() reads number.



4: how do you copy a txt document adn paste it someplace else?

read the file, store it in a string and write the string in another place



5: How do you delete a text document?

Dunno. But you can skip



Thanks in advance.
?
2016-12-24 21:52:13 UTC
Welllll... I won't supply you the respond (sounds like an task to me...) yet it relatively is the gist of it, could desire to be elementary adequate which you are able to jot down. long tale short... Use an int->string converter (e.g. itoa()) and do a loop including to the final created itemizing. easily like this filenamebase = the elementary folder call with no variety eventual itemizing = "drive_you_want_it_on:" // word it could desire to have : on the top and be a string for (num=start up num; num < optimal you opt for for; enhance num) { eventual itemizing = "" + eventual itemizing + inttostring(num) create itemizing eventual itemizing } that could desire to do it. reason you upload the on the commencing up of each and every era is to make the itemizing creation extra user-friendly. EDIT: And the answer below, regardless of the undeniable fact that it relatively works is C -no longer- C++, you would be shot for handing in that code lol! learn the recent() operator!
2009-06-08 10:17:29 UTC
5 move it into the trash (Mac) or recycling bin (windows) on your computer.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...