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); }

20th May 2019, 3:47 PM
Dzondzula
Dzondzula - avatar
3 odpowiedzi
+ 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
20th May 2019, 4:03 PM
Ipang
+ 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.
20th May 2019, 7:11 PM
Ipang
+ 1
Ive added int main and free(s) but still same thing function does not take 1 argument...what should i add?
20th May 2019, 6:48 PM
Dzondzula
Dzondzula - avatar