473,387 Members | 1,455 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,387 software developers and data experts.

please find the error in this program

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. main ( )
  3. {
  4.     int i = 1;
  5.     int *p=&i;
  6.     q=p;
  7.     int *q = 5;
  8.     printf("%d \n",*p);
  9. }
Dec 7 '19 #1
3 1961
dev7060
636 Expert 512MB
A variable cannot be used before its declaration.
Dec 8 '19 #2
donbock
2,426 Expert 2GB
Also, main must return int.
Dec 16 '19 #3
dev7060
636 Expert 512MB
If the return type is not specified, it is implicitly declared as int.

According to C99 rationale (http://port70.net/~nsz/c/c99/)
A new feature of C99: In C89, all type specifiers could be omitted from the declaration specifiers in a declaration. In such a case int was implied. The Committee decided that the inherent danger of this feature outweighed its convenience, and so it was removed. The effect is to guarantee the production of a diagnostic that will catch an additional category of programming errors. After issuing the diagnostic, an implementation may choose to assume an implicit int and continue to translate the program in order to support existing source code that exploits this feature.
From C99 or later, warnings are likely to be generated: "-Wimplicit-int" (https://gcc.gnu.org/onlinedocs/gcc/W...arning-Options).

On testing the above code with TDM-GCC 4.9.2 64-bit Release, no warning was there.

With GNU GCC, "warning: return type defaults to 'int' [-Wimplicit-int]" -> likely targeting the C99 or later version.
Dec 17 '19 #4

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

Similar topics

4
by: muser | last post by:
Can anyone run this program through their compiler or if they can see a logical error please point it out. I have my tutor working on it at the moment but I would rather a less ambigious response...
3
by: Yang Zhang | last post by:
Here is a program: ///////////////////////////////////////////////// #include <iostream> using namespace std ; class A { int a ; A(const A& aA) { a=aA.a ; cout<<"copy constructor...
10
by: Protoman | last post by:
Could you tell me what's wrong with this program, it doesn't compile: #include <iostream> #include <cstdlib> using namespace std; class Everything { public: static Everything* Instance()
12
by: GRoll35 | last post by:
I get 4 of those errors. in the same spot. I'll show my parent class, child class, and my driver. All that is suppose to happen is the user enters data and it uses parent/child class to display...
9
by: goosen_cug | last post by:
This program is a "Sequential List" class I want to do the Union Operation,Intersection Operation of the Set.But this program have a problem: /////////////////////////// Compiling... Set.cpp...
2
by: DBC User | last post by:
I have a program which ccan be called multiple times. Each time, it will open a window and the windows title has unique name. I do not have any control over this program. I want to know is there a...
1
by: =?Utf-8?B?SkQ=?= | last post by:
ok, I got a windows xp home edition computer from my friend, it is a custom made one. The windows xp is an OEM product, so microsoft is willing to charge me $59 to tell me how to fix it since its...
12
by: broli | last post by:
#include<stdio.h> #include<stdlib.h> struct point { double x, y, z;
1
by: jobie | last post by:
i am currently reading Francis Glassborow's You can do it .i tried building this program using vs2008 // first program typed in by // on #include "playpen.h" #include <iostream> int...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.