strtok

    1熱度

    1回答

    我有一個基本的.txt文件,其中可能包含的數據量完全以這種格式存在,並且我需要在'= '標識符。例如: variable1=Hello variable2=How variable3=Are variable4=You? 我需要提取「你好」「如何」「是」和「你?」並將它們存儲到一個數組中(刪除/忽略變量名稱)並能夠單獨調用每個單詞。我在C做這個,現在是我的。 #include <stdi

    -2熱度

    2回答

    while(token != NULL) { // for(position = strcspn(str,token); position >= 0; // position = strcspn(str, token + 1)); // { // str2[position] = count++; // }

    -4熱度

    1回答

    這是的strtok函數的例子...我需要一個解釋用於該塊: while (pch != NULL) { printf ("%s\n",pch); pch = strtok (NULL, " "); } return 0; 尤其pch = strtok (NULL, " "); #include <stdio.h> #include <string.h> int

    0熱度

    1回答

    我有一個功能,需要一個char ** const作爲參數,文件指針。我想要做的是在文件中,如果我看到帶有空格的行,我會從行中刪除「\ r \ n」字符並將其存儲在我的變量中。但是,將變量打印出來後,我似乎得到了奇怪的輸出。 文本文件: TestFILE NUMBER 1 whiteSpaceHere MoreWhiteSpace .. 正如你所看到的,我有一個包含公然空格兩行。 我具備

    1熱度

    3回答

    我試圖在c中將char *轉換爲大寫字母,但功能toupper()在此處不起作用。 我試圖得到temp的值的名稱,名稱是冒號前的任何東西,在這種情況下它是「測試」,然後我想充分利用名稱。 void func(char * temp) { // where temp is a char * containing the string "Test:Case1" char * name; nam

    -1熱度

    1回答

    我需要使用strtok函數來分析某些字符串中的每個單詞。 我寫了這樣的代碼: char *token; token=strtok(string,symbol); while(token!=NULL){ functionX(token); //this is a function that anlayze the token token=strtok(NULL,symbol)

    0熱度

    3回答

    我有一個文件,其中有一些由製表符分隔的字段。總是會有17級的標籤,但有順序可以不同,如.. 75104\tDallas\t85\t34.46\t45.64 75205\tHouston\t\t37.34\t87.32 93434\t\t\t1.23\t3.32 當我在下列方式使用strtok while (fgets(buf, sizeof(buf), fp) != NULL) {

    1熱度

    1回答

    我試圖在使用strtok的每個逗號後加起來的字符,但我不知道從哪裏開始?其中是存儲inputString的實際值的變量? tok + = tok;真的沒有道理,但我只能想到atm。我也有一個單獨的函數,將字符串轉換爲int,我在這裏也添加了嗎?假設函數被稱爲char strint(void); char addtotal (void) { char inputString[LINE_L

    0熱度

    1回答

    我正在使用此代碼的項目: #include <string.h> void setup() { Serial.begin(9600); } void loop() { if (Serial.available()) { String input = String(Serial.read()); Serial.println("original: " + input); cha

    1熱度

    3回答

    #include "stdio.h" #include "string.h" #include "stdlib.h" char *strArray[40]; void parsing(char *string){ int i = 0; char *token = strtok(string, " "); while(token != NULL)