找到關於C語言的1356篇文章

在C語言中使用fflush(stdin)

Samual Sam
更新於2020年6月24日 11:27:30

7K+ 次瀏覽

函式fflush(stdin)用於重新整理流的輸出緩衝區。如果成功,則返回零;否則,返回EOF,並設定feof錯誤指示符。以下是C語言中fflush(stdin)的語法:int fflush(FILE *stream); 以下是一個C語言中fflush(stdin)的例子:示例 線上演示#include <stdio.h>#include <stdlib.h>int main() { char s[20] = "Helloworld"; printf("The string : %s", s); fflush(stdin); return 0; }輸出The string : Helloworld

C語言中的ispunct()

karthikeya Boyini
更新於2020年6月24日 11:28:00

96次瀏覽

ispunct()函式用於檢查傳遞的字元是否為標點符號。如果不是標點符號,則返回零;否則,返回非零值。以下是C語言中ispunct()的語法:int ispunct(int character); 以下是一個C語言中ispunct()的例子:示例 線上演示#include <stdio.h>#include <ctype.h>int main() { int a = '!'; int b = 'a'; if(ispunct(a)) printf("The character is a punctuation."); else printf("The character is not a punctuation."); if(ispunct(b)) printf("The character is a punctuation."); else printf("The character is not a ... 閱讀更多

C語言中的strspn()

Samual Sam
更新於2020年6月24日 11:28:22

153次瀏覽

strspn()函式用於計算第一個字串中子字串的長度,該子字串存在於第二個字串中。它返回該子字串的長度。以下是C語言中strspn()的語法:size_t strspn(const char *string1, const char *string2); 以下是一個C語言中strspn()的例子:示例 線上演示#include <stdio.h>#include <string.h>int main() { const char s1[] = "Helloworld!"; const char s2[] = "Hello"; int length = strspn(s1, s2); printf("The length of string : %d", length); return 0; }輸出The length of string : 5

C/C++中的strcoll()

karthikeya Boyini
更新於2020年6月24日 11:14:50

201次瀏覽

strcoll()函式用於使用特定於語言環境的排序序列比較兩個字串。它返回:- 零,當兩個字串相同時;大於零的值,當第一個字串大於第二個字串時;小於零的值,當第一個字串小於第二個字串時。以下是C語言中strcoll()的語法:int strcoll(const char *first_string, const char *second_string); 以下是一個C語言中strcoll()的例子:示例 線上演示#include <stdio.h>#include <string.h>int main () { const char s1[] = "Helloworld"; const char s2[] = "Blank"; char *result; result = strcoll(s1, s2); if(result > 0) ... 閱讀更多

C語言中的strpbrk()

Samual Sam
更新於2020年6月24日 11:16:33

1K+ 次瀏覽

strpbrk()函式用於查詢第一個字串的第一個字元,並將其與第二個字串的任何字元匹配。如果找不到匹配項,則返回NULL;否則,返回指向第一個字串中與第二個字串字元匹配的字元的指標。以下是C語言中strpbrk()的語法:char *strpbrk(const char *string1, const char *string2)以下是一個C語言中strpbrk()的例子:示例 線上演示#include <stdio.h>#include <string.h>int main () { const char s1[] = "Helloworld"; const char s2[] = "Blank"; char *result; result = strpbrk(s1, ... 閱讀更多

C語言中的scanf()和fscanf()

karthikeya Boyini
更新於2020年6月24日 11:17:07

2K+ 次瀏覽

scanf()函式scanf()函式用於在C語言中從stdin讀取格式化輸入。它返回寫入其中的字元總數,否則返回負值。以下是C語言中scanf()的語法:int scanf(const char *characters_set)以下是一個C語言中scanf()的例子:示例 線上演示#include <stdio.h>int main () { char s[20]; printf("Enter a string : "); scanf("%s", s); printf("Entered string : %s", s); return(0); }輸出Enter a string : Peter! Entered string : Peter!fscanf()函式fscanf()函式用於從給定的流中讀取格式化輸入... 閱讀更多

C語言中%d和%i格式說明符的區別

Samual Sam
更新於2020年6月24日 11:17:57

2K+ 次瀏覽

格式說明符%d格式說明符%d將整數作為帶符號的十進位制整數取值,這意味著值無論是否為負數都應為十進位制。以下是一個C語言中格式說明符%d的例子:示例 線上演示#include <stdio.h>int main() { int v1 = 7456; int v2 = -17346; printf("The value in decimal form : %d", v1); printf("The value in negative : %d", v2); return 0; }輸出The value in decimal form : 7456 The value in negative : -17346格式說明符%i格式說明符%i將整數作為整數取值,這意味著... 閱讀更多

C/C++中的atol()、atoll()和atof()函式

karthikeya Boyini
更新於2020年6月24日 11:18:30

625次瀏覽

atol()函式atol()函式將字串轉換為長整數。如果未執行任何轉換,則返回零。它返回轉換後的長整數值。以下是C++語言中atol的語法:long int atol(const char *string)以下是一個C++語言中atol()的例子:示例 線上演示#include <iostream>using namespace std;int main() { long int a; char str[20] = "538756"; a = atol(str); cout<<

C/C++中的iswdigit()函式

karthikeya Boyini
更新於2020年6月24日 11:09:44

176次瀏覽

iswdigit()函式是C/C++中的內建函式。它檢查寬字元是否為十進位制數字。它在C++語言中宣告在“cwctype”標頭檔案中,而在C語言中宣告在“ctype.h”標頭檔案中。它接受單個字元,稱為寬字元。從0到9的字元被分類為十進位制數字。如果寬字元不是數字,則返回零(0)。如果字元是數字,則返回非零值。以下是C++語言中iswdigit()的語法:int iswdigit(ch)以下是一個C++語言中iswdigit()的例子:示例 線上演示#include <iostream>#include <cwctype>... 閱讀更多

C/C++中的towupper()函式

Samual Sam
更新於2020年6月24日 11:10:04

183次瀏覽

iswupper()函式是C/C++中的內建函式。它將寬字元轉換為大寫。它在C++語言中宣告在“cwctype”標頭檔案中,而在C語言中宣告在“ctype.h”標頭檔案中。它接受單個字元,稱為寬字元。如果字元是大寫,則將其轉換為大寫,否則不進行任何修改。以下是C++語言中towupper()的語法:wint_t towupper( wint_t ch );以下是一個C++語言中towupper()的例子:示例#include <iostream>#include <cwctype>#include <locale>using namespace std;int main() { wchar_t s[] = L"hello world!"; wcout<<towupper(s[0])<<endl; ... 閱讀更多

廣告
© . All rights reserved.