IDE C


Forum: Apps
Topic: IDE C
started by: kipman725

Posted by kipman725 on Sep. 03 2007,20:32
Hello I am learning c and would like to be able to complie aplications that I make and use some kind of editor that understands the language so can highlight apropriatly on my laptop that runs DSL.  On windows I use Dev-c++ which apears to work fine so something like that would be best.  My laptop isn't very fast (266mhz 196mb ram 4gb HD).

Also will I have to change my programs so they can run inside linux ? currently there very simple and are only use ansi complatible functions (is that the correct phrase??) anyway I will inculde an example of my source code to clarify:

Quote

/* total cost calculator - calculates the price of items */
#include <stdio.h>
main()
{
     float base, vat = 1.175, post, final;
     
     printf("\nItem Calc - with beeps!");
     
     printf("\a\nPlease input the the base price of the item: ");
     scanf(" %f", &base);
     
     printf("\a\nPlease input the postage+packing charge: ");
     scanf(" %f", &post);
     
     final = (base * vat) + post;
     
     printf("\a\nThe total is: %.2f", final);
     return 0;
}

/* don't forget the apersands! */


I started to learn c because it's what the linux kernel is wrote in and I rearly want to be able to help out one day  :)

Posted by roberts on Sep. 03 2007,20:58
Not an IDE but....

Use Beaver or Nano editor to change your
#include <stdio.h>

to

#include <tcclib.h>

Then compile with tcc

tcc -o totcost  totcost.c

tcc is built into DSL and is OK for small programs like this.
Later you can use the extension that provides gcc
But with a slow computer you can have fun with tcc

There is a tcc tutorial in the download - current - documentation section.

Posted by ^thehatsrule^ on Sep. 04 2007,00:06
If you don't wish to use tcc, you could use a fully featured compiler... one of the gcc* extensions would be ideal.

If I remember, beaver has syntax highlighting (though not sure of the defaults in DSL), but it's just an editor.  For an IDE I've used KDevelop, but it's rather heavy on resources.  Personally, I prefer using vim with syntax highlighting, autotabbing, etc.  Here's a list that could be handy: < http://linuxmafia.com/faq/Devtools/ides.html >

Some misc notes on your code (subject to opinion?):
- specify the return type i.e. int main
- no newline at the end of the last printf?
- it's ampersand ;p

Posted by kipman725 on Sep. 04 2007,10:19
I think I already have gcc installed so I mayaswell use that, with gcc can I use the <stdio.h> header file still or it there a different one to use?
I'm not sure what is ment by "specify the return type i.e. int main", could you give an example?

Posted by mikshaw on Sep. 04 2007,12:49
Quote
I'm not sure what is ment by "specify the return type i.e. int main"
Specify what type of data will be returned by a function. In the case of main, it is always (or nearly always?) going to be an integer. So instead of using "main()" you use "int main()"

Posted by curaga on Sep. 04 2007,14:38
gcc uses stdio.h. Nano has also syntax highlighting while being awesomely light, but the ver in DSL doesn't have highlighting enabled..
Posted by kipman725 on Sep. 04 2007,14:46
I got it working :D
a.out seems a strange file name though.
< http://www.kipman725.co.uk/Images/firstprog.png >

Posted by curaga on Sep. 04 2007,16:21
Nice wallpaper & theme ;)

a.out is the default name, you could've also used "gcc cost.c -o cost"

Posted by ^thehatsrule^ on Sep. 04 2007,16:27
That's just the default name... use `gcc myprog.c -o myprogname` for example

EDIT: hah beat me to it ;p

Posted by kipman725 on Sep. 04 2007,16:43
Bever has syntax highlighting which is working for me well enough not to be bothered about nano (although I do slightly prefer working from the command line).  One problem I am having is that my keymap is wrong and so I keep having to copy and paste slashes and quotation marks.  Any idea on how to change the keymap to GB?

(thanks for all the help everyone!)

Posted by ^thehatsrule^ on Sep. 04 2007,17:32
Keymap can be changed in DSLPanel > Keyboard
If one that you want isn't listed, you can download them and run the utility again.

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.