2016-09-18 54 views

回答

0

嘗試包括,如下所示:

#include <stdlib.h> //use <> instead of "" 

此外, 「printf的」 功能來自「cstdio」庫,所以嘗試實現該庫,以及

#include <stdio.h> 

修訂

到解決這個問題是最簡單的方法;

附上stdio.h中庫

#include <stdio.h> 

然後,不是打字;

printf('s'); 

你做什麼,

printf("s"); 

現在,如果你真的想要打印的字符 'S',然後使用,

printf("%c", 's'); // Tells the printf function that 's' is a character 

最後的代碼如下所示;

#include <stdio.h>  
int main(int argc, char** argv) { 
    printf("s"); 
    printf("%c", 's'); 
    return 0; 
} 

現在,您的評論是「cout」不起作用。爲了讓「COUT」工作,你需要包括iostream庫:

#include <iostream> 

然後,你可以在你的代碼中使用「COUT」;

std::cout << 's'; 
std::cout << "s"; 

或者你也可以包括 「空間std」 和 「的iostream」 庫,以避免使用std :: 「COUT」

include <iostream> 
using namespace std; 

此後,使用前COUT沒有的std ::

cout << 's'; 
cout << "s"; 

最終的代碼是;

#include <iostream> 
using namespace std; 

int main(int argc, char** argv) {  
    cout << 's'; 
    cout << "s"; 
    return 0; 
} 

如果您想了解更多關於什麼是iostream庫,以及如何,我建議使用該站點使用它:

http://www.cplusplus.com/reference/iostream/

此外,對於標準輸入輸出。H,

http://www.cplusplus.com/reference/cstdio/

+0

它仍然無法正常工作。實際上,當我包含iostream並使用namespace std時,「... cout ...」行也不起作用。所以我認爲這不是由於這個原因。 –

+0

我編輯(更新)瞭解決問題的一步一步的答案。 – ArtiomLK

相關問題