Novice C language learning journey(5)
This code has a error when run it,the compiler shows "[Warning] return makes integer from pointer without a cast".
Why it shows this error?
The "world" function is char type.So the return type must be char type.But the formal parameter of "world" function is "char*" type.
So the type is not match.The code as follows:
#include"stdio.h"
char world(char name[5]){
strcpy(name,"abs");
printf("%s",name);
return(name);
}
int main(void){
char a[12];
world(a);
return 0;
}
So how to modify?
the solution as follows:
#include"stdio.h"
char* world(char name[5]){
strcpy(name,"abs");
printf("%s",name);
return(name);
}
int main(void){
char a[12];
world(a);
return 0;
}
Congratulations @sky-999! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :
You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word
STOP
Do not miss the last post from @steemitboard:
Vote for @Steemitboard as a witness to get one more award and increased upvotes!