954,496 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Do you have any idea what this means?

int main()
{
       int var;
       char string[50];
       
       (var, string);
       (0);
       (0, 1, 2);
 
       return 0;
}



Reply ASAP
Thanks in advance
Govinda Attal.

govinda.attal
Newbie Poster
2 posts since Sep 2006
Reputation Points: 16
Solved Threads: 0
 

Several no-ops? What is your question?

Dave Sinkula
long time no c
Team Colleague
5,058 posts since Apr 2004
Reputation Points: 2,780
Solved Threads: 314
 

Hi govinda.attal ,
This means nothing.

mostafadotnet
Junior Poster
157 posts since Jul 2006
Reputation Points: 55
Solved Threads: 11
 

This code does compile and generates an exe file...When I went thru disassembly, I found nothing useful in it...There were no nops in it. First of all our basic coding principles say that it should give a compiler error... compilers like msvc, gcc simply pass without giving any error or warnings..

govinda.attal
Newbie Poster
2 posts since Sep 2006
Reputation Points: 16
Solved Threads: 0
 
This code does compile and generates an exe file...When I went thru disassembly, I found nothing useful in it...There were no nops in it. First of all our basic coding principles say that it should give a compiler error... compilers like msvc, gcc simply pass without giving any error or warnings..


I compiled to assembly and peeked at it too. The compiler just optimizes the NOPs out, so you pretty much get stack allocation and stack deallocation and that's it.

Infarction
Posting Virtuoso
1,580 posts since May 2006
Reputation Points: 683
Solved Threads: 53
 

Why would compiller give an error? That's a valid program.

Grunt
Junior Poster
152 posts since Jul 2006
Reputation Points: 197
Solved Threads: 12
 
This code does compile and generates an exe file...When I went thru disassembly, I found nothing useful in it...There were no nops in it. First of all our basic coding principles say that it should give a compiler error... compilers like msvc, gcc simply pass without giving any error or warnings..


gcc var.c -o var -Wall
var.c: In function `main':
var.c:6: warning: left-hand operand of comma expression has no effect
var.c:8: warning: left-hand operand of comma expression has no effect
var.c:8: warning: left-hand operand of comma expression has no effect
var.c:6: warning: statement with no effect
var.c:7: warning: statement with no effect
var.c:8: warning: statement with no effect

andor
Posting Whiz in Training
276 posts since Jun 2005
Reputation Points: 251
Solved Threads: 29
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You