The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Noob question on comparing #'s. kirkm76 UNIX for Dummies Questions & Answers 6 05-16-2007 11:03 AM
Noob sorting question Hexabah UNIX for Dummies Questions & Answers 1 02-11-2007 04:57 AM
complete noob avdrummerboy UNIX for Dummies Questions & Answers 3 12-04-2006 12:25 PM
I am a unix noob alt+f4 UNIX for Dummies Questions & Answers 4 04-28-2006 09:01 PM
question about JAVA compiling .. ANAMIKA56 SUN Solaris 7 08-11-2005 11:03 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-03-2006
arya6000 arya6000 is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 8
Question about compiling (noob)

I'm just getting started to lean C and I'm using Ubuntu today I found a tutorial at this site: http://einstein.drexel.edu/courses/C..._tutorial.html and I got an error after compiling the fist code:

Code:
#include < stdio.h>

void main()
{
    printf("\nHello World\n");
}
I try to compile it with: "cc hello.c" and got this error:

Code:
arya@arya-computer:~/Desktop$ cc hello.c
hello.c:1:20: error:  stdio.h: No such file or directory
hello.c: In function ‘main’:
hello.c:5: warning: incompatible implicit declaration of built-in function ‘printf’
hello.c:4: warning: return type of ‘main’ is not ‘int’
Why isn't this working is it because I'm using Ubuntu instead of FreeBSD?
  #2 (permalink)  
Old 12-04-2006
ramesh.jella ramesh.jella is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 22
do this

hi arya
you have to know that it may not have space before stdio.h
just gothrough your code

#include <stdio.h>

void main()
{
printf("\nHello World\n");
}

do this
  #3 (permalink)  
Old 12-06-2006
arya6000 arya6000 is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 8
Quote:
Originally Posted by ramesh.jella
hi arya
you have to know that it may not have space before stdio.h
just gothrough your code

#include <stdio.h>

void main()
{
printf("\nHello World\n");
}

do this


Now it gives this error

Code:
arya@arya-computer:~/Desktop$ cc hello.c
hello.c:1:19: error: stdio.h: No such file or directory
hello.c: In function ‘main’:
hello.c:5: warning: incompatible implicit declaration of built-in function ‘printf’
  #4 (permalink)  
Old 12-06-2006
nathan nathan is offline VIP Member  
Supporter
  
 

Join Date: Jul 2006
Posts: 156
The return type of main should be int, not void. The code below compiled & ran fine on my computer. Does Ubuntu use gcc? ( If so, your version of 'cc' is possibly a link to 'gcc'. ) I'm using gcc and it worked.

Code:
#include <stdio.h>

int main()
{
printf("\nHello World\n");
}
  #5 (permalink)  
Old 12-06-2006
arya6000 arya6000 is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 8
Quote:
Originally Posted by nathan
The return type of main should be int, not void. The code below compiled & ran fine on my computer. Does Ubuntu use gcc? ( If so, your version of 'cc' is possibly a link to 'gcc'. ) I'm using gcc and it worked.

Code:
#include <stdio.h>

int main()
{
printf("\nHello World\n");
}
same thing when I use gcc, do you think there is something wrong with the compiler? I'm sorry if this sounds stupid, but one of first lines says: hello.c:1:19: error: stdio.h: No such file or directory should there be a file called stdio.h in the same folder as my .c file is?

Code:
arya@arya-computer:~/Desktop$ gcc hello.c
hello.c:1:19: error: stdio.h: No such file or directory
hello.c: In function ‘main’:
hello.c:5: warning: incompatible implicit declaration of built-in function ‘printf’
  #6 (permalink)  
Old 12-06-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,121
change this:
Code:
#include < stdio.h>
to this - loose the trailing space after '<'
Code:
#include <stdio.h>
  #7 (permalink)  
Old 12-10-2006
arya6000 arya6000 is offline
Registered User
  
 

Join Date: Nov 2006
Posts: 8
k guys, I found the problem, gcc was not installed properly, now it is and now I have a file called a.out after compiling it. How can I run it?
Closed Thread

Bookmarks

Tags
linux, ubuntu

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:03 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0