使用 C 語言列印一個字串而不使用任何引號
這是另一個棘手的問題。在此程式中,我們將看到如何在 C 中使用沒有引號的字串進行列印。
此處我們使用宏函式。我們正在定義宏函式,如下所示
#define getString(x) #x
getString() 是一個宏函式。它透過將 x 轉換為字串來返回 x。x 前面的 # 表示該函式將 x 轉換為字串。
Input: Take one string without quote Output: Print that string into console
演算法
Step 1:Take a string without quote Step 2: Use macro function to print it into a string Step 3: End
示例程式碼
#include<stdio.h>
#define getString(x) #x
//The # will convert x into a string
main() {
printf(getString(Hello World));
}輸出
Hello World
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP