LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Solaris / OpenSolaris (https://www.linuxquestions.org/questions/solaris-opensolaris-20/)
-   -   segmentation error (https://www.linuxquestions.org/questions/solaris-opensolaris-20/segmentation-error-620890/)

ray.shashi 02-13-2008 01:33 PM

segmentation error
 
Hi
I am using solaris machine in which I use gcc compile.
I am getting segmentation error in the following statement
fprintf(stream_pointer_name, "\t%c16%c16%c16%c16%c", '|','|','|','|','|');
I am trying to print '|' five times in a file at a 16 spacing gap.
Can any one tell me the reason?

ehawk 02-13-2008 05:43 PM

Not sure....whenever I get a segmentation error, it is normally because I am trying to access a memory location which does not exist.

jlliagre 02-13-2008 05:56 PM

The segmentation violation is more likely due to something wrong with your stream pointer. There is also a problem with your output format.
Here is something that match your requirements:
Code:

fprintf(fp, "\t%16c%16c%16c%16c%16c", '|','|','|','|','|');

ray.shashi 02-15-2008 01:43 PM

Hi
I got the reason for segmentation error(fault).
Actually I was declaring a pointer n by mistake I
was not allocating the space for that pointer before use


All times are GMT -5. The time now is 10:15 PM.