there is no expected output of this program because it is obviously
implement dependent. if you really want to know the results, try to
run it. if you want to know why, dump the assemble code to check it
manually.
anyway, I do not think this topic is related to this group.
On Tue, Jan 6, 2009
bottomline - bad code!
The pointer returned by modify() is not guranteed (although it may depending
on compiler implementation) to hold good as the local array goes out of
scope once the function returns!
The output of the 2nd printf is undefined.
On Mon, Jan 5, 2009 at 1:18 PM, tania hamid wr
Oops. I mis-read the problem!! I didn't realized numbers are being knocked
off the list in every iteration, I somehow thought that the struck out
numbers retain their position. Sorry about the confusion!!!
On Tue, Jan 6, 2009 at 11:16 AM, Pratyush Tewari
wrote:
>
> No... lucky numbers can be comp
nothing is printed as buffer is local to modify function, it cannot be
returned.
"He who speaks,Does not Know...He who knows, Does not speak..."
http://students.iiit.ac.in/~koushik_c/
On Tue, Jan 6, 20
hmmm is should print Hello!!! with H Capital
On Tue, Jan 6, 2009 at 2:18 AM, tania hamid wrote:
>
>
> Plz indicate the output of the following code and explain why is it so..
>
>
> *char *modify (char *s)
> {
> #define MAX 15
> char buffer[MAX];
> strcpy (buffer, s);
>
> buffer[0] = 'H';
Good show Pratyush! You proved that "Lucky Numbers" is not a subset of prime
numbers. I think Vijay has missed a point in the definition of "lucky
number". When they remove every third number from the resulting sequence, it
doesn't mean removing every third from the original sequence (multiples of
the code is wrong and unsafe, because you use char buffer[MAX], what is
local varieable defined on stack. it is only valid while the modify
procedure is executing
You only have the option to use global or static variable, or second
parameter, or allocate memory on your own using new, or malloc etc.