c

    3熱度

    1回答

    我寫了這個代碼來管2個命令: // ls -l | tail -n 2 int pfd[2]; pid_t pid; char *cmd1[] = {"ls", "-l", 0}; char *cmd2[] = {"tail", "-n", "2", 0}; pipe(pfd); pid = fork(); if (pid == 0) // child { dup2

    -1熱度

    2回答

    我需要做一些數學運算。基本上用一個用戶輸入的數字除以64,然後乘以64,但爲了正常工作,需要在乘以之前完全去除小數。 例子: 150 is entered 150/64 = 2.34375 (need it to just be 2) 2 * 64 = 128 output = 128

    1熱度

    4回答

    我做了以下問題在Hackerrank: https://www.hackerrank.com/challenges/staircase?h_r=next-challenge&h_v=zen 基本上,代碼打印出一個右對齊的「樓梯」提出的「#」字符。所以,如果輸入的是6,則輸出是: # ## ### #### ##### ###### 這是解決方案(在C)我想出

    2熱度

    1回答

    我想編寫一個函數,可以讓我在某個位置插入一個鏈表到另一個鏈表這樣如果鏈表是: list1: [1]->[2]->[3]->NULL list2: [4]->[5]->[6]->NULL 然後調用該函數: insertList(list1, list2, 1); 修改list1,使得: list1 = [1]->[4]->[5]->[6]->[2]->[3]->NULL 和list2保

    1熱度

    2回答

    我在嘗試從文件中過濾特定單詞並將它們寫入新文件時遇到了一些問題。 我想要做的只是寫下'&'之後的單詞,直到第一個數字。 例如(這是我從讀文件的內容): & some 12 test1 test2 $ thisword 4 no no no no 對於上面的輸入,我只想一些和thisword寫入到一個新文件的話。 我的代碼正在工作,但不是隻打印這些文字,而是打印垃圾。 int main (ar

    0熱度

    1回答

    我有下面的結構實現鏈表: struct _node { int item; struct _node *next; } struct _list { struct _node *head; struct _node *tail; int size; } 我想編寫一個克隆鏈表的函數,而無需修改原始返回一個新的列表。我知道如何使用_node

    0熱度

    2回答

    我正在開發的項目 - 礦山掃地機遊戲 - 要求當用戶保持空閒狀態並且不要在一分鐘內輸入某些東西時被更新。這正是教授所說的:「當用戶閒置一分鐘,更新時間。」 所以我怎麼知道scanf在一分鐘內沒有返回任何東西,這樣我就可以採取一定的行動。因爲根據我的理解,scanf函數必須掃描某些內容才能繼續下一行。

    -5熱度

    1回答

    出於某種原因,我無法寫入從scanf_s我在Visual Studio 2013中使用的ch字符類型我嘗試了間距「%c」兩種方式「%c」,並嘗試scanf和scanf_s。我搞不清楚了。 // Alphabetic Pyramid Program - The Egyptians must have used C! #include <stdio.h> int main(void) {

    -3熱度

    2回答

    int towerh; do{ printf ("give me an integer between 1 and 23 and I will make a tower"); int towerh = GetInt(); }while (towerh < 1 || towerh > 23); 我試圖讓只要towerh這個代碼塊循環不是1到23之間我不斷收到錯誤,稱該變量

    -5熱度

    2回答

    一個簡單的配置文件和解析器我創建了一個配置文件,這樣 smartphones = 50; laptops = 30; watches = 20; 當程序運行時,我想它的配置設置加載到下面列出的程序變量。 int smartphones, laptops, watches; 謝謝! 編輯: 有一個測試,我做了解析我的配置文件中的文本。無論如何,我認爲代碼不好。建議? int count = 0; i