[algogeeks] Re: find the output

2009-01-06 Thread Miroslav Balaz
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

[algogeeks] Re: find the output

2009-01-06 Thread Ramaswamy R
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

[algogeeks] Re: find the output

2009-01-06 Thread chitta koushik
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,

[algogeeks] Re: find the output

2009-01-06 Thread daizi sheng
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

[algogeeks] Re: find the output

2009-01-06 Thread aliwajdan ali
hmmm is should print Hello!!! with H Capital On Tue, Jan 6, 2009 at 2:18 AM, tania hamid tan3...@gmail.com 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]

[algogeeks] Re: Lucky numbers

2009-01-06 Thread Channa Bankapur
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 3).

[algogeeks] Re: Lucky numbers

2009-01-06 Thread Vijay Venkat Raghavan N
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 tewari.praty...@gmail.comwrote: No...