windows equivalent of snprintf

Hello Group Members,
Can anyone tell me the windows equivalent of snprintf.
printf and sprintf does not work in this case.
snprintf(char *str, size_t n, char const *fmt, ...);
Thanks in advance.














































Comments

  • : Hello Group Members,
    : Can anyone tell me the windows equivalent of snprintf.
    : printf and sprintf does not work in this case.
    : snprintf(char *str, size_t n, char const *fmt, ...);
    : Thanks in advance.
    :
    :

    [blue]Its not a windows function, but a compiler function. Your compiler may or may not support it. VC++ 6.0 does. According to MSDN it is not an ansii standard function.[/blue]

  • : : Hello Group Members,
    : : Can anyone tell me the windows equivalent of snprintf.
    : : printf and sprintf does not work in this case.
    : : snprintf(char *str, size_t n, char const *fmt, ...);
    : : Thanks in advance.
    : :
    : :
    :
    : [blue]Its not a windows function, but a compiler function. Your compiler may or may not support it. VC++ 6.0 does. According to MSDN it is not an ansii standard function.[/blue]

    [blue]
    stober is correct. Borland also supports those functions.
    The Win32 API eq. of those functions simpy have an appended "w".
    For example:[/blue][code]
    sprintf (...);[green]// standard versin[/green]
    [blue][b]w[/b]sprintf (.args the same.);[/blue][green]// Win32 API ver.
    [/green][/code][blue]
    Of course you have to #include [/blue]
  • not correct == snprintf() does not do the same thing as wsprintf(), which is the UNICODE version of sprintf(). snwprintf() is the UNICODE version of snprintf().
  • [blue]
    I have tried it in VC++ 6.0 and it is producing the same result

    [b]The displayed error Is:[/b]
    [red]"display.obj : error LNK2001: unresolved external symbol _snprintf"[/red]

    I included #include

    How do I resolve it??? ...

    [/blue]




    : not correct == snprintf() does not do the same thing as wsprintf(), which is the UNICODE version of sprintf(). snwprintf() is the UNICODE version of snprintf().
    :

  • : [blue]
    : I have tried it in VC++ 6.0 and it is producing the same result
    :
    : [b]The displayed error Is:[/b]
    : [red]"display.obj : error LNK2001: unresolved external symbol _snprintf"[/red]
    :
    : I included #include
    :
    : How do I resolve it??? ...
    :
    : [/blue]
    :
    :


    Post code. I just tried it and had no problems.
    [code]
    #include

    int main(int argc, char* argv[])
    {
    char str1[] = "Hello World";
    char buf[255];
    _snprintf(buf,sizeof(buf),"%s
    ", str1);
    printf("%s
    ",buf);
    return 0;
    }
    [/code]

  • : [blue]
    : I have tried it in VC++ 6.0 and it is producing the same result
    :
    : [b]The displayed error Is:[/b]
    : [red]"display.obj : error LNK2001: unresolved external symbol _snprintf"[/red]
    :
    : I included #include
    :
    : How do I resolve it??? ...
    :
    : [/blue]

    This means that the header files are present but the required libraries
    are not - which is causing a linking error for you.

    :
    :
    :
    :
    : : not correct == snprintf() does not do the same thing as wsprintf(), which is the UNICODE version of sprintf(). snwprintf() is the UNICODE version of snprintf().
    : :
    :
    :


  • [red][size=4]Thanks[/size][/red],[blue] for giving the clue to check my mistake.
    I had infact used snprintf() and it showed the error.
    When I used _snprintf() the error resolved.
    [/blue]




    [code]........

    : : [blue]
    : : I have tried it in VC++ 6.0 and it is producing the same result
    : :
    : : [b]The displayed error Is:[/b]
    : : [red]"display.obj : error LNK2001: unresolved external symbol _snprintf"[/red]
    : :
    : : I included #include
    : :
    : : How do I resolve it??? ...
    : :
    : : [/blue]
    : :
    : :
    :
    :
    : Post code. I just tried it and had no problems.
    : [code]
    : #include
    :
    : int main(int argc, char* argv[])
    : {
    : char str1[] = "Hello World";
    : char buf[255];
    : _snprintf(buf,sizeof(buf),"%s
    ", str1);
    : printf("%s
    ",buf);
    : return 0;
    : }
    : [/code]
    :
    :
    [/code]
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories