C++ – Warnings using format strings with sprintf() in C++


Compiling this lines

    long int sz;
    char tmpret[128];

    //take substring of c, translate in c string, convert to int, 
    //and multiply with 1024


I read two warning on snprintf line:

 warning: conversion lacks type at end of format
 warning: too many arguments for format

Why? The type is specified (long int sz, and %l in snprintf) and the argument in snprintf is only one. Can anybody help me? Thanks.

Best Solution

Your format lacks type, because l is a "sizeof" modifier. Should be %ld

Related Question