【发布时间】:2017-06-27 19:50:55
【问题描述】:
我目前正在参加 CS50 哈佛课程,但遇到了问题集 2。 我制作了这个程序,它采用名称并打印首字母,它在命令行中采用名称。如何使用 get_string() 代替 argv,而 argc 非常不正统和草率,所以我可以提示用户给我她/他的名字。谢谢你。
#include <cs50.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
int main(int argc, string argv[])
{
//How do I use Get_string() so I don't have to use argv and argc??
//iterate over strings on the vector (words)
for (int i = 0; i < argc; i++)
{
//prints the 0 character of each string, use "toupper" to convert into capital letters
printf("%c", toupper(argv[i][0]));
}
printf("\n");
}
【问题讨论】:
标签: cs50