Re: Error in "vfprintf"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/15/05, Pavan G <aakashvani@xxxxxxxxx> wrote:
> On 8/15/05, Pavan G <aakashvani@xxxxxxxxx> wrote:
> > #include <stdio.h>
> > #include <math.h>
> > #include <string.h> 
> > #include <stdlib.h> 
> > #include <ctype.h>
> > struct cdnates
> > {float X,Y,Z;};
> > struct cdnates  pro[1960], gle[206][14];
> > FILE
> >
> *input,*input2,*input3,*input4,*outputs,*outputs1,*outputs2,*outputs3,*outputs4,*outputs5,*outputs6,*outputs7;
> > main()
> > {
> >   char w[10], w1[10], w2[10],ww[10];
> >   float xavg,yavg,zavg,dist1,dist2,x2,y2,z2;  
> >   int sh1=0,sh2=0,sh3=0,sh4=0,sh5=0,sh6=0,sh7=0,p0=0,g1=0,a,c=0,g0=0,
> m=20;
> >   double sqrt(double);
> > ...
> > ...
> > ....
> >      printf("%d %d %d %d %d %d %d
> > \t%4.1f\n",sh1,sh2,sh3,sh4,sh5,sh6,sh7,((double)m/10));
> >       fprintf(outputs1,"\t%4.1f\t %d\n",((double)m/10),sh1);
> >       //fprintf(outputs2,"\t%4.1f\t %d\n",((double)m/10),sh2);      
> >       //fprintf(outputs3,"\t%4.1f\t %d\n",((double)m/10),sh3);
> >       //fprintf(outputs4,"\t%4.1f\t %d\n",((double)m/10),sh4);
> >       //fprintf(outputs5,"\t%4.1f\t %d\n",((double)m/10),sh5);
> >       //fprintf(outputs6,"\t%4.1f\t %d\n",((double)m/10),sh6);
> >       //fprintf(outputs7,"\t%4.1f\t %d\n",((double)m/10),sh7);
> >     }
> >   return 0;
> > }
> > =================================================
> > Now, when I run the above program, I get a error (Segmentation fault
> > actually).
> > [root@head 20-80wt]# gdb she -q
> > (gdb) b main
> > Breakpoint 1 at 0x8048589: file allweight.c, line 21.
> > (gdb) r fff
> > Starting program: /home/pavan/amber/20-80wt/she fff
> > 
> > Breakpoint 1, main () at allweight.c:21
> > 21	  int sh1=0,sh2=0,sh3=0,sh4=0,sh5=0,sh6=0,sh7=0,p0=0,g1=0,a,c=0,g0=0,
> > m=20;
> > (gdb) b fprintf
> > Breakpoint 2 at 0x4205a178
> > (gdb) c
> > Continuing.
> > 37 15 20 60 42 32 0 	 0.1
> > 
> > Breakpoint 2, 0x4205a178 in fprintf ()
> >    from /lib/i686/libc.so.6
> > (gdb) c
> > Continuing.
> > 
> > Breakpoint 2, 0x4205a178 in fprintf ()
> >    from /lib/i686/libc.so.6
> > (gdb) c
> > Continuing.
> > 
> > Program received signal SIGSEGV, Segmentation fault.
> > 0x420502ea in vfprintf () from /lib/i686/libc.so.6
> > (gdb) c
> > Continuing.
> > 
> > Program terminated with signal SIGSEGV, Segmentation fault.
> > The program no longer exists.
> > (gdb) quit
> > =============================================
> > 
> > If you observe, the progran has a slew of "fprintf" prompts. The
> > segfault DOESNOT occur when I comment out all the fprintf's except the
> > first one or when I comment out all the fprintf's.
> > However, when I run the program with more than the first fprintf 
> > active, I see a segfault.
> > I'll be greatful if you could help me in this regard.
> > 
> > Pavan
> >
>


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux