visual studio 2010 - Max string length using scanf -> ANSI C - Stack Overflow
Recommend the fgets(buffer, sizeof(buffer), stdin) approach. If you still want to use scanf() you can create its format at runtime. #define MAX_STR_LEN 100 char format[2 + sizeof(size_t)*3 + 4 + 1]; // Ugly magic # sprintf(format, " %%%zu[^\n]", (size...