I am using VS code on Ubuntu 20.04. I am learning C programming. The program is to count length of array using function. while running the program I can give input to the array but not getting the length of array.The code is :
#include<stdio.h>#include<string.h>int length(char input[]){ int count=0; for(int i=0;input[i]!=0;i++) { count++; } return count;}int main(){ char name[10]; printf("Enter name:"); scanf("%s",&name[10]); int count=length(name); printf("%d",count);}
Output:
Enter name:abc*** stack smashing detected; terminatedAborted (core dumped)
What is wrong with the code?