I can't print a string with printf in compiler, the code works fine in an online compiler. What can be wrong?
Example of a code just to make you sure that the code is correct:
Code:#include <stdio.h> int main() { char string1[20]; char string2[] = "string literal"; printf("Enter a string: "); scanf_s("%s", string1); printf("string1 is %s,\nstring2 is %s,\nstring1 with spaces between characters is:\n",string1,string2); for (int i=0;string1[i]!='\0';i++) { printf("%c ", string1[i]); } return 0; }