473,799 Members | 3,077 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

analyze output plz

Plz
i need full explanation ?
#include<stdio. h>
int main()
{
for(;0;)
printf("hello") ;
return 0 ;
}

Why o/p results 'hello'?
Nov 14 '05 #1
5 1324
Sweety wrote:
Plz
i need full explanation ?
#include<stdio. h>
int main()
{
for(;0;)
printf("hello") ;
return 0 ;
}

Why o/p results 'hello'?


It doesn't, at least not on my system:

russell@axiom% cat > hello.c
#include<stdio. h>
int main()
{
for(;0;)
printf("hello") ;
return 0 ;
}
russell@axiom% tcc -o hello hello.c
russell@axiom% ./hello
russell@axiom%

Nor should it output anything, as far as I can tell. The for loop never
executes, because the loop condition is always false (0).

--
Russell Hanneken
eu*******@cbobk .pbz
Use ROT13 to decode my email address.
Nov 14 '05 #2

"Sweety" <sw************ @yahoo.co.in> wrote in message
news:11******** *************** ***@posting.goo gle.com...
Plz
i need full explanation ?
#include<stdio. h>
int main()
{
for(;0;)
printf("hello") ;
return 0 ;
}

Why o/p results 'hello'?


It shouldn't. Which implementation are you trying this with?

(Note that if you happened to accidentally put a semicolon after the
'for' expression-list, you'd see the "hello" output. Is this the
*exact* code?)

-Mike
Nov 14 '05 #3


Sweety wrote:
Plz
i need full explanation ?
#include<stdio. h>
int main()
{
for(;0;)
printf("hello") ;
return 0 ;
}

Why o/p results 'hello'?


Wasn't this beat to death (in this newsgroup) a week or
so ago?

--
Ron Collins
Air Defense/RTSC/BCS
"I have a plan so cunning, you could put a tail on it and call it a weasel"

Nov 14 '05 #4


Sweety wrote:
Plz
i need full explanation ?
#include<stdio. h>
int main()
{
for(;0;)
printf("hello") ;
return 0 ;
}

Why o/p results 'hello'?


Wild stab in the dark - you had a previous version of this code with a
semi-colon after the for... line. You compiled that then changed the
code to the above and forgot to re-compile it before executing it.

Ed.

Nov 14 '05 #5
sw************@ yahoo.co.in (Sweety) writes:
Plz
i need full explanation ?
#include<stdio. h>
int main()
{
for(;0;)
printf("hello") ;
return 0 ;
}

Why o/p results 'hello'?


You asked almost exactly this same question here on July 26, with the
subject "problem with for loop". I'm glad to see that you learned
*something* from the lengthy thread that resulted, since you're now
declaring "int main()" rather than "void main()", and you've added a
"return 0". ("int main(void)" would be even better, and you should
still have a newline at the end of the output, so apparently you
weren't completely paying attention.)

Also, it's not obvious to everyone that "o/p" means "output"; please
spell out the word.

You give no indication that you've posted this question before,
causing several people who didn't see the previous thread to waste
their time going over the same things.

The program as posted should produce no output on any conforming
implementation.

You received several possibly useful answers at the time. One was that
an extra semicolon:
"for (;0;);"
would explain what you're seeing, but you never actually confirmed
that the program you posted is *exactly* the same as the one you
compiled and executed. Another is that it's a known bug in Turbo C++
3.0. I suspect that's the actual explanation, but we have no way to
confirm it. If you can, try the same program with a different
compiler.

If you want our help, you need to pay more attention, participate in
the discussion, and answer followup questions. If the answers you got
the first time weren't good enough, asking the same question again
will only get you the same answers again.

Are you using Turbo C++ 3.0?

Is the code you posted the *exact* code that you compiled and executed?

Can you try the same code with a different compiler?

What led you to write this code in the first place? Writing a loop
like "for (;0;)" makes no sense in a real program; there are easier
ways to do nothing. Is there some underlying issue that you're trying
to understand, with the above code being an example that illustrates
it? If so, you'll get more meaningful answers if you'll tell us what
the actual point is. If you're just quizzing us, a lot of us are
probably willing to play along, but it's polite to let us know that
that's what you're doing rather than helping with a real-world
problem. Conversely, if it is a real-world problem, some background
would help us to understand it.

We're happy to help if we can, but you have to help us; so far, you
haven't.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Nov 14 '05 #6

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

Similar topics

3
4054
by: Code4u | last post by:
We have a mature project that suffers long build times because many modules pull in far more than they need. In the long term I would like to refactor to break some of the dependencies, but I would like to start by eliminating unneeded header includes. Is there a tool that can parse a set of source files and identify redundancies?
6
3496
by: Holger Marzen | last post by:
Hi all, the docs are not clear for me. If I want (in version 7.1.x, 7.2.x) to help the analyzer AND free unused space do I have to do a vacuum vacuum analyze or is a
3
1615
by: Harry Broomhall | last post by:
I asked earlier about ways of doing an UPDATE involving a left outer join and got some very useful feedback. This has thrown up a (to me) strange anomaly about the speed of such an update. The input to this query is a fairly large (the example I'm working with has 335,000 rows) set of records containing numbers to be looked up in the lookup table. This lookup table has 239 rows.
3
2236
by: Joseph Shraibman | last post by:
Trying this: VACUUM VERBOSE ANALYZE; on a 7.4.1 database only does a vacuum, not the analyze. I've tried this on two seperate databases. Is this a known bug? I haven't seen anything about it. ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster
11
1165
by: Sweety | last post by:
#include<conio.h> #include<stdio.h> # define swap(a,b) temp=a; a=b; b=temp; void main( ) { int i, j, temp; clrscr() ; i=5; j=10;
0
2012
by: Rajesh Kumar Mallah | last post by:
Greeting, Will it be an useful feature to be able to vacumm / analyze all tables in a given schema. eg VACUUM schema.* ; at least for me it will be a good feature.
5
3637
by: Jon Lapham | last post by:
I have been using the EXPLAIN ANALYZE command to debug some performance bottlenecks in my database. In doing so, I have found an oddity (to me anyway). The "19ms" total runtime reported below actually takes 25 seconds on my computer (no other CPU intensive processes running). Is this normal for EXPLAIN ANALYZE to report a total runtime so vastly different from wall clock time? During the "explain ANALYZE delete from msgid;" the CPU is...
16
2220
by: Ed L. | last post by:
I'm getting a slew of these repeatable errors when running ANALYZE and/or VACUUM ANALYZE (from an autovacuum process) against a 7.3.4 cluster on HP-UX B.11.00: 2004-09-29 18:14:53.621 ERROR: Memory exhausted in AllocSetAlloc(1189) This error is in the FAQ, but that answer does not appear applicable. The error is occurring on 2 different databases, on multiple tables, and all tables involved are frequently updated.
16
1203
by: =?UTF-8?B?SXbDoW4gU8OhbmNoZXogT3J0ZWdh?= | last post by:
Mo wrote: Instead of echo()ing everything, store it in a string variable. Then, sum what you need to, then echo() the sum, then echo() the string holding the (delayed) output. Cheers, -- ----------------------------------
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9538
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
10473
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
10249
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...
0
10025
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9068
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...
0
5461
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...
1
4138
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2937
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.