473,608 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Is it declaration or defination?

Hi
main() {
int x; /* it declaration or defination??*/
}

Aug 18 '06 #1
25 2786

venky wrote:
main() {
int x; /* it declaration or defination??*/
}
int x; is always a definition;
extern int x; may be a declaration.

Aug 18 '06 #2
venky schrieb:
Hi
main() {
int main(void) {
int x; /* it declaration or defination??*/
}
http://en.wikipedia.org/wiki/Declara...ter_science%29

Decide yourself.

--
Thomas
Aug 18 '06 #3

int x; /*is a declaration */

Aug 18 '06 #4
declaration

lovecreatesbeau ty wrote:
venky wrote:
main() {
int x; /* it declaration or defination??*/
}

int x; is always a definition;
extern int x; may be a declaration.
Aug 18 '06 #5
venky wrote:
int x; /* it declaration or defination??*/
It is both.

x is declared, and storage is assigned, which makes it a definition.

Aug 18 '06 #6
eahaa wrote:
int x; /*is a declaration */
Inside the function body it is also a definition, since it's not
declared "extern." The example was inside some function called main,
which is a separate issue.
Aug 18 '06 #7
cs*****@gmail.c om wrote:
declaration

lovecreatesbeau ty wrote:
>venky wrote:
>> main() {
int x; /* it declaration or defination??*/
}
int x; is always a definition;
extern int x; may be a declaration.
The top-poster says it's a declaration, which it is, but it is also a
definition (not a "defination ").

The declaration of the function in its definition in the example should
be according to one of the the prototypes int main(void); or int
main(int, char**);
Aug 18 '06 #8
venky wrote:
main() {
int x; /* it declaration or defination??*/
}
Both.

Definition is a special case of declaration, that is, all definitions
are also declarations.

Aug 18 '06 #9
On 18 Aug 2006 00:49:34 -0700, in comp.lang.c , "venky"
<ve************ ****@gmail.comw rote:
>Hi
main() {
int x; /* it declaration or defination??*/
}
Its a declaration and a tentative definition, which will become a firm
definition if no other definition is encountered.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Aug 18 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3034
by: Guo Congbin | last post by:
·¢¼þÈË: "Guo Congbin" <guocongbin@sei.buaa.edu.cn> Ö÷Ìâ: is size_t a keyword?or a macro? ÈÕÆÚ: 2004Äê6ÔÂ17ÈÕ 23:04 if size_t is a macro, where is the defination? i look it up in the stddef.h, but i find nothing about size_t. this is the content of stddef.h of my system, #ifndef _LINUX_STDDEF_H #define _LINUX_STDDEF_H
8
1818
by: scl | last post by:
two class with same name exist in different dynamic linked library: a.so class REGION() { public: .... ~REGION() {} } b.so
1
644
by: DIA | last post by:
Can we find the defination of a SQL stored procedure using c#? 1. Using SQL-DMO in c# I was able to locate a SQL server in the network. 2. Hit the target database in the selected server. 3. Get object of SQLDMO._StoredProcedure class point to the stored procedures which i need to refer. I am stuck at findding the parameters and their for the
18
2486
by: shaanxxx | last post by:
I have following code . #include<stdio.h> int i; int i; int i; int main() { printf("%d",i); return 0;
1
1625
by: Johnny E. Jensen | last post by:
Hello I have a class that inherence from the ToolStrip control called (AWToolbar), and i added my own methods to that class. Then i have a usercontroll (QuickNavigator), and I add the AWToolbar, by dragging it onto the usercontrol. It works OK At this state my InitializeComponent() looks like: this.awToolbar1 = new Aware.WControls.AWToolbar();
6
2391
by: romeshkumar | last post by:
what is the difference between declaration and defination?
2
1295
by: Gunners | last post by:
#include<iostream.h> #include<conio.h> #include<stdio.h> #include<stdlib.h> struct st_base { char name; int roll_no; int s1,s2,s3,s4,mks; float percentage;
0
8003
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8498
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8478
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8152
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6817
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6014
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3962
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4025
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1331
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.