On Dec 12, 2007 8:54 PM, mano M <[EMAIL PROTECTED]> wrote:

> i need to use %s and %d in sscanf function. It is not actually working as I 
> expected .I simulated the issue using a sample program.
>
>   #include<stdio.h>
> int main()
> {
> char str[100]="hello|67";
> char s1[10];
> int num;
> sscanf(str,"%s|%d",s1,&num);
> printf("%s",s1);
> }
>
>   output: hello|67

I don't think sscanf will parse string like that without whitespace,
it's going to read the entire string at once. I think strtok() will
work better for splitting the string on the | character.

-- Brett
------------------------------------------------------------
"In the rhythm of music a secret is hidden;
    If I were to divulge it, it would overturn the world."
               -- Jelaleddin Rumi

Reply via email to