我想知道如何在C中使用单词? [英] I was wondering how to use words in C?
本文介绍了我想知道如何在C中使用单词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是开始使用C并且有一个关于在c中使用某些字符而不是整数的问题的问题,这里我有一个简单的评分程序,我将如何使用say someones name而不是数字来评论关于该特定名称,如果输入了不同的名称,将显示不同的消息?
感谢任何帮助,谢谢!
#include < stdio.h >
#include < conio.h >
void main()
{
< span class =code-keyword> int 等级;
printf( 输入你的等级:);
scanf_s( %d,& grade);
如果(等级& gt; = 60 )
{
printf( 您通过了);
}
else
{
printf( 难以忘怀);
}
_getch();
}
解决方案
C中的单词是字符串。
这将解释:
http://www.tutorialspoint.com/cprogramming/c_strings.htm [ ^ ]
和此处:
http://www.tenouk.com/clabworksheet/labworksheet6。 html [ ^ ]
所以从这个链接:
// name是一个数组变量,稍后会详细介绍......
// 表示保留65字节的存储空间,包括已终止的
< span class =code-comment> // string,'\ 0'
char Initial,Name [ 65 ];
// 向用户提示......
printf( 输入名称,初始和存款:\ n);
printf( 你叫什么名字?);
// 读取用户输入并将数据存储在...
scanf( %64s,名称);
I've only started using C and have a question about using characters like someones name in c instead of integers, here i have a simple grading program below, how would i go about using say someones name instead of a number to comment about that particular name and if a different name is entered a different message would show?
Any help is appreciated, Thanks!
#include<stdio.h>
#include<conio.h>
void main()
{
int grade;
printf("Enter Your Grade:");
scanf_s("%d", &grade);
if (grade >= 60)
{
printf("You passed");
}
else
{
printf("Hard Luck You Failed");
}
_getch();
}
解决方案
Words in C are character strings.
This will explain:
http://www.tutorialspoint.com/cprogramming/c_strings.htm[^]
and here:
http://www.tenouk.com/clabworksheet/labworksheet6.html[^]
So from this link:
// name is an array variable, more on this later... // means reserve 65 bytes of storage including terminated // string, '\0' char Initial, Name[65]; // some prompt to user... printf("Input name, initial and deposit:\n"); printf("What is your name? "); // read the user input and store the data at... scanf("%64s", Name);
这篇关于我想知道如何在C中使用单词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文