ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
As Sergei has said this has nothing to do with the IDE, rather the setting that you use for the compiler. Assuming that you are using gcc (or the IDE is) check the man pages to understand the most appropriate settings for your needs. Here is an online version which can be easier to navigate, look for -std= option.
As Sergei has said this has nothing to do with the IDE, rather the setting that you use for the compiler. Assuming that you are using gcc (or the IDE is) check the man pages to understand the most appropriate settings for your needs. Here is an online version which can be easier to navigate, look for -std= option.
Code:
$gcc -std=c89
?
If that that is correct will it do any harm to Ubuntu since it uses C in other apps?
compiling a program with an earlier C standard and then running it on Ubuntu will be fine. compiling Ubuntu using the old standard will most likely give you grief.
compiling a program with an earlier C standard and then running it on Ubuntu will be fine. compiling Ubuntu using the old standard will most likely give you grief.
So it works but I should not recompile Ubuntu before I change it back?
mattias@SNAR-PC-01:~/NetBeansProjects/Charater Counting$ cat programmet.c
#include<stdio.h>
main(){
long nc;
int c;
nc = 0;
while((c = getchar()) !=EOF)
nc++;
printf("%1d\n", nc);
Code:
mattias@SNAR-PC-01:~/NetBeansProjects/Charater Counting$ gcc -std=c89 -g -Wall programmet.c
programmet.c:2: warning: return type defaults to ‘int’
programmet.c: In function ‘main’:
programmet.c:8: warning: format ‘%1d’ expects type ‘int’, but argument 2 has type ‘long int’
programmet.c:9: warning: control reaches end of non-void function
Compiles it and -g add support for debugging and -wall will generate warnings. a.out is now created in the same directory as programmet.c
This solves the thread but in the process I discovered that I actually don't need an ANSI-C IDE because there is nothing wrong with the code so far. EOF is Ctrl D not '\n'(enter) which I thought it was
FAIL
ideone.com is probably not ANSI-C the EOF is submit which explains why it works better than NetBeans.
...in the process I discovered that I actually don't need an ANSI-C IDE because there is nothing wrong with the code so far. ...
...
First of all, the wrong thing is your understanding of programming reality - as long as you see compiler warning and do nothing about them, thinking nothing is wrong with your code, your understanding of programming reality is wrong.
The very basic principle is: first make the code formally correct, i.e. with zero compiler warnings, and only then it might work.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.