| | |
Basic Concept
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2004
Posts: 68
Reputation:
Solved Threads: 1
C Syntax (Toggle Plain Text)
# include<stdio.h> void main() { int p; p = (1,2,2,100,1); printf("%d",p); }
I dont know what will be the output . Can anyone please tell me what exactly second line implies ?? :rolleyes:
comma ' , ' operator has left to right associativity
In this case output will be 1
But if we apply ( )
then last value is assigned to p and output will be 2
C Syntax (Toggle Plain Text)
# include<stdio.h> void main() { int p; p = 1,2; printf("%d",p); }
But if we apply ( )
then last value is assigned to p and output will be 2
•
•
Join Date: Sep 2005
Posts: 3
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by harshchandra
C Syntax (Toggle Plain Text)
# include<stdio.h> void main() { int p; p = (1,2,2,100,1); printf("%d",p); }
I dont know what will be the output . Can anyone please tell me what exactly second line implies ?? :rolleyes:
if p were an array, then the initializer list would have to be in braces, not parentheses, like this
But the above is entirely different than the code you originally posted.
C Syntax (Toggle Plain Text)
int p[] = {1,2,2,100};
But the above is entirely different than the code you originally posted.
•
•
Join Date: Sep 2005
Posts: 1
Reputation:
Solved Threads: 0
># include<stdio.h>
>void main()
>{ int p;
> p = 1,2;
> printf("%d",p);
>}
>In this case output will be 1
what will be the output, if i make a bit of change in the existing code, i mean:::
# include<stdio.h>
void main()
{ int p = 1,2;
printf("%d",p);
}
i got error in this case, i dont know , why its producing error in this case, when it looks similar to the old one??
>void main()
>{ int p;
> p = 1,2;
> printf("%d",p);
>}
>In this case output will be 1
what will be the output, if i make a bit of change in the existing code, i mean:::
# include<stdio.h>
void main()
{ int p = 1,2;
printf("%d",p);
}
i got error in this case, i dont know , why its producing error in this case, when it looks similar to the old one??
![]() |
Similar Threads
- Hamming codes encoder/decoder in C or C++ (C++)
- Clearing b-4 selling... (Storage)
- accessing common user-defined functions (ASP.NET)
- Help me please? (Java)
- Im new (C++)
- Adding controls into a ListView (Visual Basic 4 / 5 / 6)
Other Threads in the C Forum
- Previous Thread: Fibonacci number
- Next Thread: strtok() function questions <C programming>
| Thread Tools | Search this Thread |
adobe ansi api array arrays asterisks bash binarysearch calculate centimeter char convert copyanyfile copyimagefile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic fflush file fork frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators infiniteloop initialization interest km linked linkedlist linux linuxsegmentationfault list locate logical_drives match matrix meter microsoft motherboard multi mysql number open opendocumentformat opensource openwebfoundation owf pattern pdf performance pointer pointers posix power probleminc program programming pyramidusingturboccodes read recursion recv repetition scanf scheduling scripting segmentationfault send shape socketprograming stack standard strchr string strings structures suggestions systemcall test testautomation unix user variable voidmain() wab win32api windows.h






