How to assign string of one variable to other variable?
问题 This is my first question on this site. How do i assign string of one variable to other variable. What am i doing wrong here? #include<stdio.h> #include<string.h> main(){ char a[30],b[30]; scanf("%s",a); b[30]=a[30]; printf("%s",b); } 回答1: Use the standard C function strcpy declared in the header <string.h> . For example strcpy( b, a ); Arrays do not have the assignment operator. As for your statement b[30]=a[30]; then b[30] and a[30] are undefined objects of the type char that are beyond the