array index out of bounds code example

Example 1: java array out of bounds

//Use index inside the bounds of the array

Example 2: error in array

#include <stdio.h>
int main()
{
	char a[20],b[10]= "String",c[8]={'S','t','r','i','n','g','\0'};
	int i;
	for(i=0;c[i]!='\0';i++){
	
	printf("%c",&c[i]);}
	printf("%s",b);
    puts(b);
    	printf("enter the string first scanf and then gets");
    	scanf("%s",a);
    	gets(a);
}#include <stdio.h>
int main()
{
	char a[20],b[10]= "String",c[8]={'S','t','r','i','n','g','\0'};
	int i;
	for(i=0;c[i]!='\0';i++){
	
	printf("%c",&c[i]);}
	printf("%s",b);
    puts(b);
    	printf("enter the string first scanf and then gets");
    	scanf("%s",a);
    	gets(a);
}

Tags:

Java Example