Dose anyone know this?

Started by
10 comments, last by ProPuke 18 years, 10 months ago
How do you(I) load(open)(run) files in C?
Advertisement
Look up fopen and fprintf, I think.
---There are 2 kinds of people: those who know hexadecimal, and those who don't.
To open files and read the contents, use fopen.
ex:
FILE* fp = fopen("hello.txt", "r");assert(fp != null);/* do stuff with the file */fclose(fp);


To run programs that is platform depedent. Usually something along the the lines of system("notepad.exe") will work.
HTHRooke-----C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg. (Bjarne Stroustrup)
I need to run a BATCH file (.bat) and none of the things yal' gave me worked.
Quote:Original post by t5hoo6
I need to run a BATCH file (.bat) and none of the things yal' gave me worked.


Umm in Unix/Linux? You could try using system to execute it, but not sure how that's done on that platform. Give it a look though! BTW, I though .BAT files were something doe Dos/Windows? I might be mistaken though, so excuse my lack of knowledge in the *nix area [wink]
How about how do you clear the screen my compiler cannot use CLS?
Quote:Original post by t5hoo6
How about how do you clear the screen my compiler cannot use CLS?


system("clear"); is the *nix version IIRC.
Using system(); is just all around bad IMHO.

Use either the ncurses or boost libraries.
Or implement it all by yourself, using ASCII escape sequences... ;)

Cheers,
Drag0n
-----------------------------"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning..." -- Rich Cook"...nobody ever accused English pronounciation and spelling of being logical." -- Bjarne Stroustrup"...the war on terror is going badly because, if you where to compare it to WWII, it's like America being attacked by Japan, and responding by invading Brazil." -- Michalson
Escape sequences are just as system-dependent as system(). They won't work on the default Windows console for example.
-Mike

This topic is closed to new replies.

Advertisement