#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char const *argv[]) {
char *a = "FUCKYOUUUUUUUUUUUUU"; //第7行
//char *a = malloc( sizeof( char ) * 15 );//第8
char b[10] = "****you";
char c[5] = "shit";
b[7]='\0';
c[4]='\0';
strcpy( a , b);
strcpy( a , c);
printf( "this one is %c\n" , a[9] );
}
为什么用第8行可以 7 不行
b,c大小知道 为什么指针a也需要一个明确的大小?
#include <stdlib.h>
#include <string.h>
int main(int argc, char const *argv[]) {
char *a = "FUCKYOUUUUUUUUUUUUU"; //第7行
//char *a = malloc( sizeof( char ) * 15 );//第8
char b[10] = "****you";
char c[5] = "shit";
b[7]='\0';
c[4]='\0';
strcpy( a , b);
strcpy( a , c);
printf( "this one is %c\n" , a[9] );
}
为什么用第8行可以 7 不行
b,c大小知道 为什么指针a也需要一个明确的大小?