get() function ?
On Thu, Sep 15, 2011 at 12:14 AM, rahul vatsa vatsa.ra...@gmail.com wrote:
ther is no get() function.
On Wed, Sep 14, 2011 at 1:55 PM, Puneet Gautam puneet.nsi...@gmail.comwrote:
I think there is no problem with the while statement, even if file is
not present , it will
Something like this was asked in written test of Tally. We had to find the
cause why this program crased during run time.
File *f;
int count=0;
if(f=fopen(file.txt,r))
{
while(f.get()!=EOF)
{
count++;
}
}
--
Regards
Ravi Maggon
B.E. CSE, Final Year
Thapar University
file not closed.
On Wed, Sep 14, 2011 at 5:56 PM, ravi maggon maggonr...@gmail.com wrote:
Something like this was asked in written test of Tally. We had to find the
cause why this program crased during run time.
File *f;
int count=0;
if(f=fopen(file.txt,r))
{
while(f.get()!=EOF)
sorry fclose was also written in the last line. I missed it while asking.
On Wed, Sep 14, 2011 at 6:10 PM, abhinav gupta guptaabhinav...@gmail.comwrote:
file not closed.
On Wed, Sep 14, 2011 at 5:56 PM, ravi maggon maggonr...@gmail.com wrote:
Something like this was asked in written test of
I guess, if file is not found, fopen will return -1.
Which will evaluate the statement
if(f=fopen(file.txt,r)) as true..
--
*Regards
Jitesh Kumar
There is only one 'YOU' in this world. You are Unique and Special.*
*Don't Ever Forget it.*
--
You received this message because you are subscribed
if file.txt is not present it gives a seg fault
and if the file is present then the problem is with f.get(), use fgetc or
fgets etc the program runs without any error
*..*
*
**Regards
Sandeep Kumar
MTech Computer Science
**IIT Madras*
Music washes away from the soul the dust of
I think there is no problem with the while statement, even if file is
not present , it will create a new file...
The problem is with f.get()but dunno what...?
On 9/14/11, sandeep kumar sandeep.crazyguy2...@gmail.com wrote:
if file.txt is not present it gives a seg fault
and if the file is
ther is no get() function.
On Wed, Sep 14, 2011 at 1:55 PM, Puneet Gautam puneet.nsi...@gmail.comwrote:
I think there is no problem with the while statement, even if file is
not present , it will create a new file...
The problem is with f.get()but dunno what...?
On 9/14/11, sandeep
What is the wrong in this program
main()
{
char *p,*q;
p=(char *)malloc(25);
q=(char*) malloc(25);
strcpy(p,INDIA );
strcpy(q,hyd);
strcat(p,q);
printf(%s,p);
}
--
With Regards,
Balaji.S
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To
What do you expect it to give ?
On Wed, Jun 22, 2011 at 4:25 PM, Balaji S balaji.ceg...@gmail.com wrote:
What is the wrong in this program
main()
{
char *p,*q;
p=(char *)malloc(25);
q=(char*) malloc(25);
strcpy(p,INDIA );
strcpy(q,hyd);
strcat(p,q);
printf(%s,p);
}
--
With
http://www.ideone.com/pubwV
On Wed, Jun 22, 2011 at 4:30 PM, PRITPAL SINGH pritpal2...@gmail.comwrote:
What do you expect it to give ?
On Wed, Jun 22, 2011 at 4:25 PM, Balaji S balaji.ceg...@gmail.com wrote:
What is the wrong in this program
main()
{
char *p,*q;
p=(char *)malloc(25);
the only thing wrong about the program is the memory leak :p
On Wed, Jun 22, 2011 at 4:30 PM, PRITPAL SINGH pritpal2...@gmail.comwrote:
What do you expect it to give ?
On Wed, Jun 22, 2011 at 4:25 PM, Balaji S balaji.ceg...@gmail.com wrote:
What is the wrong in this program
main()
{
@pritpal : Refer ques 5 at
http://www.youthrocker.com/2011/06/interview-questions-amazon-placement.html
@shachindra : wats tat :-o
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
@balaji
I think memory leak is the only problem with the code.
rest is fine
On Wed, Jun 22, 2011 at 6:03 PM, Balaji S balaji.ceg...@gmail.com wrote:
@pritpal : Refer ques 5 at
http://www.youthrocker.com/2011/06/interview-questions-amazon-placement.html
@shachindra : wats tat :-o
--
You
@balaji, the memory allocated from the heap using malloc needs to be
released before termination of the program. there should be two additional
statements as follows:
free(p);
free(q);
On Wed, Jun 22, 2011 at 6:09 PM, PRITPAL SINGH pritpal2...@gmail.comwrote:
@balaji
I think memory leak is
memory leak and memory allocation check, make sure malloc return non-null.
On Wed, Jun 22, 2011 at 7:04 PM, Shachindra A C sachindr...@gmail.com wrote:
@balaji, the memory allocated from the heap using malloc needs to be
released before termination of the program. there should be two additional
@Balaji : the code given by u compiles and runs successfully in gcc
compiler and gives the correct answer i.e. INDIAhyd . What's the
problem ??
@Shachindra A C : Which memory leak are you talking about ?? The
memory allocated from the heap using malloc need not be released
before termination of
@Vishal : Ya this seems to be correct..
On Wed, Jun 22, 2011 at 7:05 AM, ankit sambyal ankitsamb...@gmail.com wrote:
@Balaji : the code given by u compiles and runs successfully in gcc
compiler and gives the correct answer i.e. INDIAhyd . What's the
problem ??
@Shachindra A C : Which memory
As vishal pointed out, checking the return val is missing and it is the
programmer's responsibility to free up the memory which he has requested
for...
On Wed, Jun 22, 2011 at 7:37 PM, ankit sambyal ankitsamb...@gmail.comwrote:
@Vishal : Ya this seems to be correct..
On Wed, Jun 22, 2011 at
19 matches
Mail list logo