On Fri, 2006-10-13 at 10:16 +0530, Sucheta Ghosh wrote:
> Let me clarify the situation one by one:
> 
> > I can see some problems here, but that's not really GTK-related;
> 
> Then my question is: how the same code works fine as a simple c file, when 
> I am not using this inside Gtk+?

Probably because you are just lucky.  Often times code that's not quite
correct can work fine in a small, standalone test case but fails when
run in another context.

By the way you never did post the runtime error message you got.
Unfortunately without knowing what that error was we cannot help you.

> 
> > 1) no error checking for fopen(), fgets() - You don't to anything
> >   if they fail (and that's most probable)
> 
> What I have written is only a small piece of code, where I had written the 
> extract only to explain the problem in short. I have done the error 
> checking, the result is fopen() is not getting the null value, but fgets() 
> is getting the null value.
> 
> And I have declared all the variables unless it would not compile, as I 
> said earlier this is a runtime problem.
> 
> > 2) can't see any fclose() - multiple "fopen()"s without closing
> >   the file is BAD :)
> 
> I have done it in my Gtk+ coding only did not shown it here.
> 
> And all the other things I have done due to the demand of my application.
> 
> Thanks & regards,
> Sucheta Ghosh
> 
> On Thu, 12 Oct 2006, Progss wrote:
> 
> > Sucheta Ghosh napisa?(a):
> >> I wished to read a file and get some lines from there like this:
> >>    -----
> >>    fp=fopen("filename", "r");
> >>    for(k=0; k<8; k++){
> >>            n=a[k];
> >>            for (i=1; i<=n; i++) //Here 'n' is the line number
> >>                    fgets(s, 100, fp);
> >>            puts(s);
> >>            rewind(fp);
> >>    }
> >>    -----
> >>    -----
> >> This is the code snippet, which is working so well after compiling with 
> >> 'gcc' compiler, but when I added this code inside Gtk+ callback.c, a 
> >> runtime error is occuring before execution of 'fgets'. I have already 
> >> included 'stdio.h', but even then it is not executing.
> >> 
> >> Do you have any idea that how to overcome this problem?
> >
> > I can see some problems here, but that's not really GTK-related;
> > well - there's also a change that included snippet was simply
> > too short
> >
> > 1) no error checking for fopen(), fgets() - You don't to anything
> >   if they fail (and that's most probable)
> >
> > 2) can't see any fclose() - multiple "fopen()"s without closing
> >   the file is BAD :)
> >
> > 3) You're reading the same file 8 times - and that's *at least*
> > non-optimal - of course that depends on what exactly you're going
> > to achieve, however I'm quite convinced
> >
> > 4) I'd be really careful about placing some external file operations
> > nside of a callback function..... but this depends on your overall
> > application purpose and design.
> >
> > Best regards
> > Waldek
> >
> > ----------------------------------------------------------------------
> > Czas pozegnac finansowe problemy.
> > Kredyt Citibank - prosty kredyt na wszystkie potrzeby.
> > Sprawdz: http://link.interia.pl/f19a5
> >
> >
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> 

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to