What do you mean by:
scanf("%50[^ ]s",kog);
?
If you want to scan till new line is printed, try:
scanf(" %49[^\n]",kog);
And by the way always mention width specifier 1 less than the size of the string. This is to avoid overwriting the terminating null character. So mention 49 instead of 50 as width specifier.
From cppreference:
If width specifier is used, matches only up to width. Always stores a null character in addition to the characters matched (so the argument array must have room for at least width+1 characters).
Also, note that a scan set conversion is complete at the ]. the structure is "%49[…]" and that's all. It is a common misapprehension that the scan set should be followed by s.
And provide a space before % in the scanf() to avoid consuming the new line character entered at the end of previous entry.
%50s. Also, you must specify a length excluding the null byte, so you need to use49and not50in the format (or change the array dimension to51) to be safe. The off-by-one is historical and hence sacrosanct, but unfortunately inconsistent with most other functions that specify a buffer length. If the numbers are on separate lines, you probably want a space before the scan set (" %49[^ ]") to skip the newline left by the prior%d.scanf("%50[^ ]s",kog);the functionscanf()for a char string input will always append a NUL byte, so the statement should be:scanf("%49[^ ]s",kog);. Also, the[...] acts to input a string, so the trailings` should not be there I.E. use:scanf("%49[^ ]",kog);