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

nested printfs

Hi,i hav executed the following c code...the inner printf executes first to print some garbage value...why dont the outer printf prints anything.....
I got only one garbage value ..y dont two garbage values...wt is the order of precedence in printf function and in nested printfs.

the c code is:

void main()
{
while(1)
{

if(printf("%d",printf("%d")))
break;
else
continue;
}
}

Thanks & Regards
Oct 26 '06 #1
3 1723
vimase
5
Hi,i hav executed the following c code...the inner printf executes first to print some garbage value...why dont the outer printf prints anything.....
I got only one garbage value ..y dont two garbage values...wt is the order of precedence in printf function and in nested printfs.

the c code is:

void main()
{
while(1)
{

if(printf("%d",printf("%d")))
break;
else
continue;
}
}

Thanks & Regards

try executing the following code,
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. int main()
  3. {
  4. while(1)
  5. {
  6.  
  7. if(printf("%d",printf("%d ")))
  8. break;
  9. else
  10. continue;
  11. }
  12. return 0;
  13. }
  14.  
you have missed out the space in the inner printf, so the two integers are bieng printed together without space in between them.
Oct 26 '06 #2
dtimes6
73
U may try it like this:
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. int main()
  3. {
  4.     while(1)
  5.     {
  6.         if(printf("A%d\n",printf("B%d\n")))
  7.             break;
  8.         else
  9.             continue;
  10.     }
  11. }
  12.  
Oct 26 '06 #3
Thanku fnds....u r right.....
Oct 26 '06 #4

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

Similar topics

6
by: Andy Baker | last post by:
Hi there, I'm learning Python at the moment and trying to grok the thinking behind it's scoping and nesting rules. I was googling for nested functions and found this Guido quote:...
3
by: Erik Bongers | last post by:
Hi, Nested classes only seem to be able to access static members of the surrounding class : class SurroundingClass { public: class InnerClass { public:
5
by: evan | last post by:
I am calling a C function from a C++ method as follows: int mem_if::read(void) { int i; for(i = 0; i < 5; i++) { printf("A"); E2Read(i); } return size; }
6
by: B0nj | last post by:
I've got a class in which I want to implement a property that operates like an indexer, for the various colors associated with the class. For instance, I want to be able to do 'set' operations...
8
by: Robert W. | last post by:
I've almost completed building a Model-View-Controller but have run into a snag. When an event is fired on a form control I want to automatically updated the "connnected" property in the Model. ...
1
by: Tomas Sieger | last post by:
Hi all, I'm in doubt with the following code: class Base { public: class Nested {}; }; class Derived:public Base { public: class Nested {
77
by: Peter Olcott | last post by:
http://www.tommti-systems.de/go.html?http://www.tommti-systems.de/main-Dateien/reviews/languages/benchmarks.html The above link shows that C# is 450% slower on something as simple as a nested loop....
11
by: charlie | last post by:
I recently came across s function (actually many) whose structure is a series of nested ifs with the meat of the function at the very centre: if (condition1) if (condition2) if (condition3) if...
3
by: jdurancomas | last post by:
Dear all, I'm trying to declare the operator++ to a nested class. The nested class is not template but the container it is. The code used in teh sample program is included bellow: ...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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...
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...

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.