473,378 Members | 1,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

I'm having trouble with my code compiling, "error: return type defaults to 'int'"

#include <stdio.h>
main() /*program which introduces keyboard input */
{
int number;

printf ("Type in a number \n");
scanf ("%d", &number);
printf ("The number you typed was %d\n", number);
}


I then try to compile with "gcc -Wall -Werror -Lm user_input.c"
but I am receiving an error. Any suggestions on how to fix my code?
Feb 12 '10 #1
2 11412
weaknessforcats
9,208 Expert Mod 8TB
You need a return type int on main():

Expand|Select|Wrap|Line Numbers
  1. int main()
  2. {
  3.  
  4. }
Not specifying a return type defaults to int in C but not in C++. Try that.
Feb 12 '10 #2
This worked perfectly!
Thank you!
Feb 13 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

32
by: Mike Machuidel | last post by:
Hi, I'm a game developer programming mostly in C and ASM for about 7 years. Today at work a colleague (a C++ programmer) yelled at me I'm a bad C programmer because I use "return(0);" instead...
10
by: LaEisem | last post by:
On-the-job, I have "inherited" a lot of old C language software. A question or two about when "casting" of null pointer constants is needed has occurred during behind-the-scenes cleanup of some...
5
by: Kevin R | last post by:
I'm trying to update a sql database. It's modified Oledb code from an example that did work with an access database. How can I tweak my code to make it work? Thanks in advance. Kevin...
3
by: John Sasso | last post by:
In my Yacc .y file I defined: %union { int value; struct Symbol Sym; } The Symbol struct I defined in a header file I #included in the Prologue section of the .y file as:
7
by: JustBeSimple | last post by:
Hi Everyone, I'm having a problem compiling useing the VS2005 .NET I need help to resolve those error, I try to create a new project it doesn't help any suggestion? I got the following errors:...
4
by: lostlander | last post by:
In ARMCC, and Microsoft C, when i use a function which is never defined or delared, it gives out a warning, not a compiling error? why? (This leads to a bug to my program since I seldom pay much...
5
by: .rhavin grobert | last post by:
guess you have the following classes... ___________________________________ class { //..a couple of methods ...// }; class A { public: //...// B* GetB() // <- this we'll talk about
2
by: Jolie Chen | last post by:
I am learning template programming now, and I wrote the following code #include <iostream> #include "Queue.h" using namespace std; template <typename Tclass QueueItem { public: QueueItem(T...
1
by: alex21 | last post by:
Ok i am trying to use a Linq query to access a dictionary. public static Dictionary<string, Client> Clients = new Dictionary<string, Client>();Using this Linq query: IEnumerable<Staff> loginquery...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.