0
Why visual studio cant do this is says "function does not take 1 arguments"
#include <stdafx.h> #include <stdlib.h> #include <stdio.h> void main(){ char *s = (char *)malloc(100); int b = 0, max = 0; gets_s(s); while (*s){ if (*s == ' ') b++; if (b > max) max = b; s++; } puts(s); }
3 Respuestas
+ 5
1. int main rather than void main.
2. function `gets_s` requires 2 arguments given, the buffer, and the buffer size.
http://en.cppreference.com/w/c/io/gets
3. Don't forget to `free(s);`
Hth, cmiiw
+ 3
Have you changed the call for `gets_s` function yet? if not, you need to work on that part, example: gets_s(s, 100);
Mind that 100 is the allocated bytes for <s>, set this value accordingly with the malloc call.
+ 1
Ive added int main and free(s) but still same thing function does not take 1 argument...what should i add?