Command-line using Dev-C++

Started by
17 comments, last by Carolina 18 years, 9 months ago
Hi there! I´d like to know how can I use command line in Dev-C++.I´m making a program that uses argc and argv[].However,I have no idea how can I call the program using Windows.My compiler is Dev-C++.Any ideas? Carol
Advertisement
Hey, i used dev cpp and i didn't have a compiler so i got borland c++ compiler. Borland is a command-line compiler and it works. Try borland, it might help, I dont know if it will work for your program because i just used it on a simple program i made. Hope this helps!
I haven't really used dev-c++, but I know it uses the MinGW compiler. Which is a windows port of gcc. So to compile stuff, you just type the command "gcc". Type "gcc --help" to learn how to use it. More commonly you use makefiles and run the "make" command (again "make --help" will tell you how to use it). I don't know if dev-c++ auto-generates make files, or what.

If non of those commands work, it means that you have to add the directory that they reside to your "path" variable. To do this on XP:
Right click My Computer,
click properties,
go to the "Advanced" tab,
click "Enviroment Variables",
Edit the "Path" variables under "System variables",
add ";c:\mingw\bin", or wherever its installed in (just search for gcc.exe, or make.exe).
There is an option to set parameters (I forget exactly what its called or what menu roll out its in) but the option will let you pass commands to argv. Its built into dev-cpp.
Oh, ha! I guess I misunderstood the question. Sorry.
I'm not sure what your asking, a lot of people seem to be thinking that you are talking about calling the compiler from the command line. However, if you are wondering how you run the program so that you can add the arguments, you simply go to the command line. On Windows 2000/XP, Go to Start->Run and type in 'cmd' without the quotes. On 9x/ME, type in 'command' without the quotes. You then just need to navigate to the directory where your program is, through the cd command, and then you just run your program with the arguments after the program name.
Scott SimontisMy political blog
Or, you can open your project, and go to Execute -> Parameters and type in the parameters you want into the little box that appears.

That has the same effect, but from within the IDE without you having to open Command Prompt and do all the dirty work yourself.

HTH,

ukdeveloper.
Or you can right click the compiled executable, click create shortcut. Then right click the shortcut, go to properties, then add your parameters to the end of the Target field.
Thanks for the replies! I still haven´t solved my problem...I mean,now I´m using the DOS-Prompt to have the program activated,like this:
C:\Documents and Settings\User>Desktop\simulator 10 5 fatorial.asm

My program is a CPU processor simulator and reads some data from a file(in this case,fatorial.asm,which is a parameter).The parameters 10 and 5 are sizes of vectors I use later in the program.Anyway,the problem is, the program doesn´t work and I have a guess it is because of this command:

FILE *fp=fopen(argv[3],"r");

This is the command I use to read the file name from argv[3] and open the "fatorial.asm" file. The program goes fine up to this command,then it stops.And YEAH,´the file exists and is in the same directory as the executable file.So,what should I do? Y.Y

Thanks a lot!
Hey,I´ve tested using the Execute->Parameters of Dev-C++ and it works fine...Why the hell DOS-Prompt doesn´t?¬¬

This topic is closed to new replies.

Advertisement