View Full Version : syntax
sossego
April 14th, 2009, 09:41
halpers.c:1:20: error: stdio.h: No such file or directory
halpers.c: In function 'main':
halpers.c:5: warning: incompatible implicit declaration of built-in function 'printf'
halpers.c:4: warning: return type of 'main' is not 'int'
Text editing files is only getting me so far. So...
is there a practical and updated set of tutorials for c and c++ that can be/ are used for freebsd?
It isn't running or editing c files that causes a problem. it's trying to write them.
graudeejs
April 14th, 2009, 13:01
show source
SirDice
April 14th, 2009, 14:14
man 3 printf
sossego
April 14th, 2009, 14:29
#include < stdio.h>
void main()
{
printf("\n Hello World \n");
}
I know, it's the standard c tutorial; but, I'm not seeing something here.
adamk
April 14th, 2009, 14:38
Look at the include line... You have an extra space in there.
Adam
sossego
April 14th, 2009, 14:45
It's the same output after editing. I am looking at a few references that say I may be missing some header/developer files. Question is which ones?
SirDice
April 14th, 2009, 14:47
No, your #include line should read:
#include <stdio.h>
There's a space in yours..
stdio.h lives in /usr/include:
dice@williscorto:~>ll /usr/include/stdio.h
-r--r--r-- 1 root wheel 14752 Apr 25 2008 /usr/include/stdio.h
SirDice
April 14th, 2009, 14:52
Works like a charm:
dice@williscorto:~/test>cat test.c
#include <stdio.h>
int main () {
printf("\nHello World\n");
return 0;
}
dice@williscorto:~/test>cc -o test test.c
dice@williscorto:~/test>./test
Hello World
dice@williscorto:~/test>
sossego
April 14th, 2009, 14:55
Minha culpa (My fault). Thanks for showing me that.
SeanC
April 14th, 2009, 15:41
[code]So...
is there a practical and updated set of tutorials for c and c++ that can be/ are used for freebsd?
It isn't running or editing c files that causes a problem. it's trying to write them.
Try to get C Primer Plus by Stephen Prata. It's more comprehensive than K&R and the author assumes that you have no programming experience. There are tons of examples, too.
SeanC
April 14th, 2009, 15:53
Also, maybe use an IDE with syntax highlighting.
LateNiteTV
April 14th, 2009, 19:36
i used to use codelite for a c ide. pretty good.
/usr/ports/editors/codelite
vBulletin® v3.8.7, Copyright ©2000-2012, vBulletin Solutions, Inc.