當前位置:首頁 » 編程語言 » c語言c保存單詞
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

c語言c保存單詞

發布時間: 2022-01-13 12:05:04

c語言的所有單詞

樓主不要像背語文課本一樣去背下來,多寫寫代碼,自然會記住的!auto :聲明自動變數
double :聲明雙精度變數或函數
int: 聲明整型變數或函數
struct:聲明結構體變數或函數
break:跳出當前循環
else :條件語句否定分支(與 if 連用)
long :聲明長整型變數或函數
switch :用於開關語句
case:開關語句分支
enum :聲明枚舉類型
register:聲明寄存器變數
typedef:用以給數據類型取別名
char :聲明字元型變數或函數
extern:聲明變數是在其他文件正聲明
return :子程序返回語句(可以帶參數,也可不帶參數)
union:聲明共用數據類型
const :聲明只讀變數
float:聲明浮點型變數或函數
short :聲明短整型變數或函數
unsigned:聲明無符號類型變數或函數
continue:結束當前循環,開始下一輪循環
for:一種循環語句
signed:聲明有符號類型變數或函數
void :聲明函數無返回值或無參數,聲明無類型指針
default:開關語句中的「其他」分支
goto:無條件跳轉語句
sizeof:計算數據類型長度
volatile:說明變數在程序執行中可被隱含地改變
do :循環語句的循環體
while :循環語句的循環條件
static :聲明靜態變數
if:條件語句
希望對你能有所幫助。

② C語言怎樣將鍵盤輸入的單詞保存在指針數組中

#define M 100;
char *s[M];
char buf[1000]; //搞個緩沖區
int i;
for(i=0;i<M;i++)
{
//?????//怎樣分配指針s指向的存儲單詞的內存空間啊?
scanf("%s",buf);
s[i]=(char*)malloc(strlen(buf)+1); // 申請內存
strcpy(s[i],buf); // 保存該單詞
}

③ 關於c語言的基本單詞

不要像背語文課本一樣去背下來,多寫寫代碼:

double :聲明雙精度變數或函數
int: 聲明整型變數或函數
struct:聲明結構體變數或函數
break:跳出當前循環
else :條件語句否定分支(與 if 連用)
long :聲明長整型變數或函數
switch :用於開關語句
case:開關語句分支
enum :聲明枚舉類型
register:聲明寄存器變數
typedef:用以給數據類型取別名
char :聲明字元型變數或函數
extern:聲明變數是在其他文件正聲明
return :子程序返回語句(可以帶參數,也可不帶參數)
union:聲明共用數據類型
const :聲明只讀變數
float:聲明浮點型變數或函數
short :聲明短整型變數或函數
unsigned:聲明無符號類型變數或函數
continue:結束當前循環,開始下一輪循環
for:一種循環語句
signed:聲明有符號類型變數或函數
void :聲明函數無返回值或無參數,聲明無類型指針
default:開關語句中的「其他」分支
goto:無條件跳轉語句
sizeof:計算數據類型長度
volatile:說明變數在程序執行中可被隱含地改變
do :循環語句的循環體
while :循環語句的循環條件
static :聲明靜態變數
if:條件語句

④ c語言用到的單詞

1.保留字:
C語言的關鍵字共有32個,根據關鍵字的作用,可分其為數據類型關鍵字、控制語句關鍵字、存儲類型關鍵字和其它關鍵字四類。
(1)數據類型關鍵字(12個):char, double, enum, float, int, long, short, signed, struct, union, unsigned, void
(2)控制語句關鍵字(12個):break, case, continue, default, do, else, for, goto, if, return, switch, while
(3)存儲類型關鍵字(4個):auto, extern, register, static
(4)其它關鍵字(4個):const, sizeof, typedef, volatile
2.控制語句:
控制語句完成一定的控制功能。C語言只有9條控制語句,又可細分為三種:
( 1)選擇結構控制語句
if()~else~, switch()~
(2)循環結構控制語句
do~while(), for()~, while()~, break, continue
(3)其它控制語句
goto, return
3。函數:

字元串函數
bcmp
b
bzero
memccpy
memchr
memcmp
memcpy
memicmp
memmove
memset
movmem
setmem
stpcpy
strcat
strchr
strcmp
strcmpi
strcpy
strcspn
strp
stricmp
strlen
strlwr
strncat
strncmp
strncmpi
strncpy
strnicmp
strpbrk
strrev
strset
strstr
strtok
strupr

數學函數
abs
acos
asin
atan
atan2
ceil
cos
cosh
exp
fabs
floor
fmod
frexp
hypot
ldexp
log
log10
modf
pow
pow10
sin
sinh
sqrt
tan
tanh

輸入輸出函數
getchar
kbhit
printf
putchar

系統庫函數
ClearScreen
DispBCD
SetScrollBar
TextOut
UpdateLCD
bell
block
clrscr
cursor
delay
get_chi_font
get_eng_font
getkey
getpixel
gotoxy
line
move
noidle
outtextxy
putpixel
pyfc
rectangle
sleep
textmode
time
write_chi_font
write_eng_font

標准函數
exit
itoa

字元函數
isalnum
isalpha
iscntrl
isdigit
islower
isascii
isgraph
isprint
ispunct
isspace
isupper
isxdigit
toascii
tolower
toupper

動態內存分配函數
calloc
free
malloc
realloc

⑤ C語言字元串存入多個單詞

中國人的姓名大都在2到4個字之間,一個漢字佔用2個位元組,再加上串結束符,所以存放姓名的數組長度有9個字元即可。學號的長度根據具體情況而定,如果是整數,可以用unsigned類型存儲,如果是字元數值混合型,則要用字元數組,成績可用float類型表示。例如
char name[9];
char No[12];
float score;

⑥ C語言把輸入的單詞保存至指針數組該怎樣操作

首先你是輸入的單詞 所以輸入輸出都得用%s

定義類型也得是基於char的

另外要求是指針數組 而你這個只是指針而不是數組

修改如下

#include<stdio.h>
#defineM100
main()
{
char*c[M];
for(i=0;i<M;i++)
c=(char*)malloc(sizeof(char)*1000);
inti;
for(i=0;i<M;i++)
{
scanf("%s",c[i]);

}
for(i=0;i<M;i++)
printf("%s ",c[i]);
for(i=0;i<M;i++)
free(c[i]);
system("pause");
}

⑦ 學習C語言必須記到的英語單詞

C語言中主要記住的是關鍵字,一般來說也不用刻意去記,因為寫的多了,用的多了,自然熟悉。C語言的常用關鍵字及意義如下所示:

⑧ C語言如何將一個字元串中的單詞分別存到另一個二維數組

/*通過gcc編譯*/
#include <stdio.h>
#include <string.h>

int isalpha(char t)
{
return( (t>='a'&&t<='z') || (t>='A'&&t<='Z') );
}

int main()
{
char line[256];
char word[128][80];
char tmp[2]={"\0\0"};
int i,length,totalNumber;
int prvIsAlpha;

while(1)
{
gets(line);
if(line[0]=='\0') break;
/*如果輸入空行的話就退出程序*/

totalNumber=0;
length=strlen(line);

/*如果當前字元是字母那麼通過判斷前一個字元是不是字母來判斷當前單詞的輸入是否斷開*/
prvIsAlpha=0;
for(i=0;i<length;++i)
if(isalpha(line[i]))
{
tmp[0]=line[i];
if(prvIsAlpha) strcat(word[totalNumber-1],tmp);
else word[totalNumber++][0]=line[i];
prvIsAlpha=1;
}
else prvIsAlpha=0;

/*輸出結果*/
if(totalNumber>1)
{
printf("There are %d words.\nThey are %s",totalNumber,word[0]);
for(i=1;i<totalNumber;++i)printf(",%s",word[i]);
printf(".\n");
}
if(totalNumber==1)
printf("There is 1 word.\nIt is %s.\n",word[0]);
if(totalNumber==0)
printf("There is no word.\n");
/*結果輸出完畢*/
}

return 0;
}

⑨ 用C語言編寫「背單詞 程序」

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct word //定義一個word的結構體,裡面的兩個成員分別放英語單詞和相應的漢語翻譯
{
char chinese[20];
char english[20];
};
int point=0; //統計分數的
int count1=0; //測試的次數

void tianjia(struct word str[100],int &count); //函數聲明,往詞庫中添加片語
void shuchu(struct word str[100],int &count); //函數聲明,輸出詞庫中所有的片語
void fanyi1(struct word str[100],int &count); //函數聲明,輸入漢語,對英語翻譯的考察
void fanyi2(struct word str[100],int &count);
void chaxun(int point,int count1); //函數聲明,輸出成績!

void main()
{

int count=0;
struct word str[100]; //定義一個結構體數組str
int n;
char ch,chioch;

while(1)
{
printf("*************背單詞系統*********************\n");
printf("*************1,添加詞庫*********************\n");
printf("*************2,漢譯英***********************\n");
printf("*************3,英譯漢***********************\n");
printf("*************4,輸出所有詞庫*****************\n");
printf("*************5,成績查詢*********************\n");
printf("*************0,退出*************************\n");
printf("********************************************\n");
printf("請輸入你要經行的操作:\n");
scanf("%d",&n);
switch(n)
{
case 1:tianjia(str,count);break; //函數調用
case 2:fanyi1(str,count);break; //函數調用
case 3:fanyi2(str,count);break; //函數調用
case 4:shuchu(str,count);break;
case 5:chaxun(point,count1);break; //函數調用
case 0:{printf("你確認要退出嗎?y/n!!\n");
scanf("%c%c",&ch,&chioch);
if(ch=='y'||ch=='Y') exit(0);
}
default :printf("你輸入了錯誤的操作,無法執行!!!");
exit(0);
}
}
}

void tianjia(struct word str[100],int &count) //往詞庫中添加片語
{
char ch;
do{
printf("錄入詞庫!!!\n");
printf("請輸入詞庫中的英語單詞:\n");
scanf("%s",str[count].english);
printf("\n請輸入相應的中文意思:\n");
scanf("%s",str[count].chinese);
count++;
printf("是否繼續錄入?y/n!!!\n");
scanf("%s",&ch);

}while(ch=='y');
printf("%d\n\n",count);
}

void shuchu(struct word str[100],int &count) // 輸出詞庫中所有的片語
{
int i=0;
printf("輸出詞庫中所有的單詞!!!\n");
if(count<=0) {printf("沒有任何單詞,無法輸出!!!\n");return;}
else {
for(i=0;i<count;i++){
printf("英文單詞是:%s",str[i].english);
printf("\n相應的中文意思是:%s",str[i].chinese);
printf("\n\n");
}
printf("詞庫所有單詞輸入完畢!!!!\n");
}
}

void fanyi1(struct word str[100],int &count) //輸入漢語,對英語翻譯的考察
{
int i;
char ch[20];
char bh[20];
printf("請輸入英語單詞:\n");
scanf("%s",ch);
printf("請輸入翻譯後的中文:\n");
scanf("%s",bh);
for(i=0;i<count;i++)
{
if(strcmp(ch,str[i].english)==0)
{
if(strcmp(bh,str[i].chinese)==0)
{
point++;
count1++;
printf("恭喜你!!答對了!!!\n");
}
else
{

count1++;
printf("很遺憾,答錯了!!!正確的翻譯是:%s\n",str[i].chinese);
}
}
}
}

void fanyi2(struct word str[100],int &count) //輸入英語,對漢語翻譯的考察
{
int i;
char ch[20];
char bh[20];
printf("請輸入中文:\n");
scanf("%s",ch);
printf("請輸入翻譯後的英文:\n");
scanf("%s",bh);
for(i=0;i<count;i++)
{
if(strcmp(ch,str[i].chinese)==0)
{
if(strcmp(bh,str[i].english)==0){
point++;
count1++;
printf("恭喜你!!答對了!!!\n");
}
else
{

count1++;
printf("很遺憾,答錯了!!!正確的翻譯是:%s\n",str[i].english);
}
}
}
}

void chaxun(int point,int count1)
{
printf("本次測試的成績是:\n");
printf("總共:%d個\n",count1);
printf("正確:%d個\n",point);
// printf("正確率為:%d\%\n",point*100/count1);
}