【发布时间】:2023-04-05 11:58:01
【问题描述】:
# include <stdio.h>
void danidev(void){
printf("Dani is a YouTuber and an indie game developer and an fps game developer having his game published in play store he is 22 years old and goes to a university");
}
void brackeys(void){
printf("brackeys is a YouTuber and an indie game developer and also an fps game developer having most of his games published in itch.io and has a team which works on game development");
}
void blackthornprod(void){
printf(" they are two brothers who create video games and teach others how to do the same over on Youtube and Udemy ! they are passionate in sharing their knowledge and game creation journey with other aspiring game developers.");
}
void jabrils(void){
printf("jabrils is a ai programmer and also a machine learning pro coder and also a game developer he has made a lot of ai and has saved millions of people from their tough times");
}
void codingbullet(void){
printf("coding bullet is a multi intelligent ai developer and also a master in machine learning also he owns a youtube channel with 2.06 million subscribers");
}
int main(){
printf("HERE IS THE INFORMATION OF FAMOUS CODING YOUTUBERS(PLS TYPE THE FOLLWOING YOUTUBERS NAME): ");
char b;
scanf("%c",&b);
if(b=='danidev'){
danidev();
}
else if(b=='brackeys'){
brackeys();
}
else if(b=='blackthornprod'){
blackthornprod();
}
else if(b=='jabrils'){
jabrils();
}
else if(b=='codingbullet'){
codingbullet();
}
else{
printf(" i dont know what you are taking about");
}
return 0;
}
当我输入 YouTube 用户的姓名(全名)作为输入时遇到问题,我遇到了一个问题,即常量太长并且无法给出正确的结果,而且它说常量字符对于它的类型来说太长了
【问题讨论】:
-
使用双引号
""创建字符串文字,而不是单引号。创建一个char数组来存储scanf的结果,并使用%s读取字符串而不是%c读取单个字符。 -
感谢克里斯蒂安·吉本斯的帮助
-
我建议您按照自己的方式完成初级 C 编程课程。网上有很多免费的。
-
嗨 bob Jarvis,我刚开始学习 c,我是一个 12 岁的孩子(有多聪明)我在 education.io 中自学 c @Bob Jarvis - Reinstate Monica
标签: c arrays if-statement input scanf