Menu

Message type invalidScanfArgType_in correct?

antred
2016-09-22
2016-09-28
  • antred

    antred - 2016-09-22

    I have a cpp file in which there's a call to sscanf(). The format specifier for the argument is %x, the argument itself is of type std::size_t*.
    .
    According to http://en.cppreference.com/w/cpp/io/c/fscanf, std::size_t* is a perfectly acceptable argument type for %x, but cppcheck complains:

    %x in format string (no. 1) requires 'unsigned int ' but the argument type is 'std::size_t * {aka unsigned long long }'.

     

    Last edit: antred 2016-09-22
  • Daniel Marjamäki

    Hello!

    Sorry for late reply.

    According to http://en.cppreference.com/w/cpp/io/c/fscanf, std::size_t* is a perfectly acceptable argument type for %x, but cppcheck complains:

    Yes. But as I read it you need the 'z' length modifier.

    I am not sure but I think something like:

    fscanf(f,"%zx", ..
    

    does that work?

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.