User forums > Using Code::Blocks
How do I, in a project, call main.c something else and have it still run?
yarly:
When I create a project in C::B, I choose console application, C
And it creates a project with the file main.c
How can I get a different filename there?
stahta01:
--- Quote from: yarly on September 19, 2015, 01:35:22 pm ---When I create a project in C::B, I choose console application, C
And it creates a project with the file main.c
How can I get a different filename there?
--- End quote ---
These are the steps I use; if you need detailed steps please ask.
1. Save the file main.c with the name I want it to have.
2. Add the saved file to the project
3. Remove main.c from the project
There are other methods; but, this is the easiest one I know of.
Tim S.
papagym:
Your subject and post are not real clear so it's not clear what you are trying to do.
If you're a newbie to programming. I suggest you learn by reading some tutorials on C or C++.
You can not change the name of the main function in C or C++. All programming starts from the main function. However you can change what is in the body of the main function does, that is what's located between the curly braces.
If you trying to change the name of the project ...main.c... all you need to do is rename it.
yarly:
Thanks. What Stah suggested, worked.
@papa
I know how to write a C program. I am not trying to change the name of the 'main' function. I am not talking about the main function. I am talking about the filename, as I said, main.c If you try writing a C program in vi, and compiling it with gcc, or even doing so with C::B outside of a project, you see the filename can be anything. Though for projects, code::blocks defaults to calling the file main.c Of my 3 line question, lines 2 and 3 show that I was just talking about filenames not the main function.
My mistake was an IDE mistake - not "adding the file to the project". I see no rename option within codeblocks(if I saw it I could take main.c that is already added and rename it). So now i'm getting it to work with file..new..empty file..yes..[name it]..save..ok (or I suppose I can right click the project and do add file).
Ta
oBFusCATed:
There is an easier way - close the file, find it in the project manager and right click -> rename.
Navigation
[0] Message Index
[#] Next page
Go to full version