how to use string in va_start?

Posted by Newbie on Stack Overflow See other posts from Stack Overflow or by Newbie
Published on 2011-01-10T15:49:23Z Indexed on 2011/01/10 15:53 UTC
Read the original article Hit count: 87

Filed under:

for some reason, i cant get this working:

    void examplefunctionname(string str, ...){
...
    va_start(ap, str.c_str());

nor do i get this work:

    void examplefunctionname(string str, ...){
...
    int len = str.length();
    char *strlol = new char[len+1];
    for(int i = 0; i < len; i++){
        strlol[i] = str[i];
    }
    strlol[len] = 0;
    va_start(ap, strlol);

but this does:

    void examplefunctionname(const char *str, ...){
...
    va_start(ap, str);

could someone show me how i can use string instead of const char * there?

its outputting random numbers when i call examplefunctionname("%d %d %d", 1337, 1337, 1337)

© Stack Overflow or respective owner

Related posts about c++