C简单问题 读写字符串

来源:百度知道 编辑:UC知道 时间:2024/06/30 05:33:54
#include<stdio.h>
#include<string.h>
#include<ctype.h>
char *dic[][40]={
"luster", "A bright shine on the surface.",
"disgree","Loss of honor and respect.",
"glamour","Strong attraction.",
"tomb", "The place wherea dead person is buried.",
"garbage","Unwanted or spoiled food.",
"bliss", "Great happiness or joy.",
"commend","Speak favorably of.",
" "," " //null end the list
};
void main()
{
char word[80],ch;
char **point;//定义一个二维指针
do
{
puts("Please enter word: ");
scanf("%s", word);
//将二维数组首地址赋给二维指针p
point = (char **)dic;
//查看字典中是否存在输入的单词,存在则输出解释
do
{
if(!strcmp(*point, word))
{
puts("The meaning of the word is: ");

注意你程序中第一次使用SCANF()的时候,在输入流中留下了一个换行符,导致你后面的那个SCANF()中的CH永远都是换行.把后面那个改为
scanf("%*c%c%*c",&ch);