davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: Which Editor for C Programs

Mon Apr 11, 2016 7:23 pm

jahboater wrote: As @buja pointed out, any topic entitled "Which is the best editor for ..." will immediately start an intense heated debate lasting forever (called an editor war). Its been true ever since the early days of usenet and probably before. This forum stands out for the decorum and patience shown by the participants!
so I think this topic can be closed.
Finally the OP already has chosen the best one for his purposes:
Geany.
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

jogl
Posts: 93
Joined: Sun Mar 13, 2016 12:02 pm
Location: SW Ontario Canada

Last Word Master Foo

Mon Apr 11, 2016 8:22 pm


Heater
Posts: 13306
Joined: Tue Jul 17, 2012 3:02 pm

Re: Which Editor for C Programs

Tue Apr 12, 2016 7:56 am

RDS,
Also, having edited the program, how do you run it.
After one week nobody has answered this question so...

1) Edit you file and save it, for example hello.c which looks like this:

Code: Select all

#include <stdio.h>

int main (int argc, char* argv[])
{
    printf("Hello world!\n");

    // Do whatever you want here...

    return (0);
}
2) Compile it with the gcc compiler with this command:

Code: Select all

$ gcc -Wall -o hello hello.c

Code: Select all

Always use the -Wall option as it shows many more warnings about mistakes you may make

3) Run you newly creted "hello" executable like so:
[email protected]:~$ ./hello
Hello world!
When you program gets big enough you will want to split the code into multiple files. You can add them to the program like so:

Code: Select all

$ gcc -Wall -o hello fileA.c fileB.c hello.c
When you code gets really big come back here and ask how to use "make" to build it.

Or...

Install qtcreator. Yes this is an IDE for developing C++ apps using the Qt GUI library but you can use it for creating regular C programs that don't use Qt as well. Mind you using Qt is a good idea.

Note: Be sure to use vim in step 1) if qtcreator is not to your liking :)

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: Which Editor for C Programs

Tue Apr 12, 2016 8:05 am

swampdog wrote:'nano'

I've used 'vi' and 'emacs' in my time. Nano (-w) beats them all.
Balderdash, poppycock, and flap-doodle!

You've clearly never used any of them! unbelievable!

:mrgreen:
marcus
:ugeek:

jahboater
Posts: 4680
Joined: Wed Feb 04, 2015 6:38 pm

Re: Which Editor for C Programs

Tue Apr 12, 2016 8:37 am

If I am explaining to someone how to edit a config file to get them going, I suggest "sudo nano xxxx.conf", not "sudo vi xxx.conf" because they (as beginners) are bound to get in a pickle in vi. emacs is not even installed by default. I think most helpers on the forum suggest nano. Nano is great for newcomers because it doesn't require any learning at all. Of course vi and emacs are infinitely more powerful.

RDS
Posts: 718
Joined: Tue Oct 06, 2015 8:17 am
Location: Lancashire, UK

Re: Which Editor for C Programs

Tue Apr 12, 2016 8:40 am

@Heater
Thank you very much. Other things have got in the way recently and I had not got round to trying it all out yet, so I had not actually realised that I would have been unable to run it!

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: Which Editor for C Programs

Tue Apr 12, 2016 9:00 am

@RDS
but did you try Geany as I had suggested?
Do you compile, build, and run your programs out of the Geany IDE?

It's the most simple way to do that for C and C++ programs IMO, especially for beginners!
Compiling out of the IDE will give you automatically all error messages and warnings which makes it easy to debug your code.
You may even configure to automatically run your program by sudo, as I suggested, setting the "run" parameter in the build properties.

Code: Select all

// e.g., 
compile: g++ -Wall -c "%f"  -pthread -lrt
make: g++ -Wall -o "%e" "%f"  -pthread -lrt
run: sudo "./%e"
http://www.mindstormsforum.de/viewtopic ... 769#p67771
http://www.mindstormsforum.de/viewtopic ... 769#p67772
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

RDS
Posts: 718
Joined: Tue Oct 06, 2015 8:17 am
Location: Lancashire, UK

Re: Which Editor for C Programs

Tue Apr 12, 2016 11:59 am

@davenull
Sorry, no I haven't had chance to try it yet as I stated in my post above (this morning). However, the method you have suggested is the one I will be trying. Thanks.

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: Which Editor for C Programs

Tue Apr 12, 2016 1:53 pm

ah, ok, I thought you just meant Heater's proposal.
good luck !
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

Return to “C/C++”