Skip to content

Instantly share code, notes, and snippets.

@dbc2201
Created November 28, 2018 07:24
Show Gist options
  • Select an option

  • Save dbc2201/77186aaf9cc32b22745aceb682d68aba to your computer and use it in GitHub Desktop.

Select an option

Save dbc2201/77186aaf9cc32b22745aceb682d68aba to your computer and use it in GitHub Desktop.
The length of the character array remains the same. It is an array afterall! The problem here is with the input buffer. It might take characters more than specified at the definition of array but then, your program is likely to misbehave. We need to check for this sort of errors while writing our code. Hence we use #define to define constants fo…
#include <stdio.h>
int main()
{
char a[] = "hello";
printf("%s", a);
for( int i = 0 ; i < 4 ; i++ )
{
scanf("%s", a);
printf("%s", a); // this will help you better understand the working
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment