c-strings

    1熱度

    2回答

    學習d並徹底享受過程,但這段代碼轉換成一個d字符串char*我百思不得其解。我無意中發現它的只是一味的直覺模板是如何工作的,但我想知道它是如何工作 import core.stdc.stdio; import core.stdc.string; import core.stdc.stdlib; extern (C): /// Convert a string to a char arr

    -1熱度

    1回答

    下面的for循環會一直持續到字符串結束,而if分支會檢查字符'u'出現在字符串「yuzuf Oztuk」中的次數,這是3次。同時,變量計數字符串中u的個數。當我編譯代碼時,我得到了15次你出現在字符串中的次數,這是錯誤的。 int numTimesAppears(char* mystring, char ch) { int i; int count; for(i =

    8熱度

    2回答

    考慮下面的代碼: constexpr auto f() { auto str = "Hello World!"; return str; } int main(int argc, char* argv[]) { static constexpr auto str = f(); std::cout << str << std::endl;

    0熱度

    2回答

    我是C語言的新手。我試圖使用strcat函數。 #include <stdio.h> #include <string.h> int main(int argc, const char *argv[]) { char s1[] = "12345"; char s2[] = "abcde"; strcat(s1, s2); puts(s1);

    0熱度

    3回答

    所以我在讀從我的C語言編程過程中的一些代碼,和對面這個問題問出來: 修剪字符串:" make trim "到"make trim"。 這是代碼: #include <stdio.h> #include <string.h> #define MAX 100 void trim(char *s) { char *d = s; while (isspace(*s++))

    1熱度

    3回答

    我有一個格式爲:[email protected] [email protected] ... [email protected]的輸入字符串。它總是由'@'和' '分隔。 實施例: [email protected] [email protected] [email protected] 它應該顯示具有最小值的人的姓名。 如何解決? 輸出: driver

    0熱度

    1回答

    我有這個項目的問題,我嘗試搜索論壇上的答案,但我什麼也沒找到。 struct orario { int hours; int minutes; int seconds; char *format; }orario1; int main(int argc, char *argv[]) { sscanf(argv[1],"%d:%d:%d %s",&orario1.hours,&ora

    3熱度

    4回答

    編輯:我曾嘗試改變線arr_of_strings[arr_index_count] = first_word;到strcpy(arr_of_strings[arr_index_count], first_word);但隨後它給打印Word is: This 編輯2後分段錯誤:我我試圖做到這一點沒有strtok,因爲我認爲這將是瞭解C字符串的好方法。 試圖學習C我自己。決定創建一個接受字符串的函數,

    1熱度

    2回答

    我有這樣的代碼: char first_word[MAX_LENGTH + 1] = "test"; printf("Word to input: %s\n", first_word); printf("Word to input: %p\n", first_word); 它成功地打印出兩個(打印字符串「Test」,然後一個地址)。 在我的代碼,我最終做到這一點: char *arr_of

    0熱度

    1回答

    我想寫一個C程序,我有一個10個字符串的數組,其中每個字符串表示停放在現場i的汽車的車牌號碼。隨機選取一個地點,如果空置,則生成一個隨機車牌號碼並將其分配到該地點,如果該地點被佔用,則該地點騰空並且車牌號碼被刪除。但是,該程序正在進入一個無限循環,這正是我想要的,但它不會打印我編寫的用於調試程序的任何語句。代碼如下: #include <stdlib.h> #include <stdio.h>