Might sound obvious ... But have you allocated memory for your string
pointer "string2"?
Michael
On Tue, 25 May 1999, Justin Ryan [PHT] wrote:
> hey guys, any idea why my program would segfault whenever I try to use
> sprintf? example program I wrote to try and find my error:
>
> #include <stdio.h>
>
> int main()
> {
> char *string;
> char *string2;
>
> string = "blah";
>
> sprintf(string2, "%s is the string", string);
>
> printf("the string says %s", string2);
>
> return (0);
> }
>
> this segfaults, if i just use printf with string it works fine.. any
> input?
>
> -Justin
>
> |--------------------------------------------------
> |Justin Ryan
> |Developer Relations / Support Associate
> |Pacific HiTech / TurboLinux
> |http://www.turbolinux.com / [EMAIL PROTECTED]
> |WebMaster, PCHelp - http://computers.iwz.com
> |[EMAIL PROTECTED]
> |--------------------------------------------------
>
> ---------------------------------------------------------------------------
> Send administrative requests to [EMAIL PROTECTED]
>
---------------------------------------------------------------------------
Send administrative requests to [EMAIL PROTECTED]