EADST

C printf Usage Guide

C printf Usage Guide

Code

 # include < stdio.h>

int main() {
    // Integer
    int intValue = 42;
    printf("Integer (%%d): %d\n", intValue);

    // Float/Double
    double doubleValue = 3.14159;
    printf("Float/Double (%%f): %f\n", doubleValue);

    // Character
    char charValue = 'A';
    printf("Character (%%c): %c\n", charValue);

    // String
    const char* stringValue = "Hello";
    printf("String (%%s): %s\n", stringValue);

    // Hexadecimal
    int hexValue = 255;
    printf("Hexadecimal (%%x): %x\n", hexValue);

    // Pointer
    int variable = 100;
    printf("Pointer (%%p): %p\n", (void*)&variable);

    // Additional examples showing formatting options
    printf("\n--- Formatting Examples ---\n");
    printf("Right-aligned (%%10d): '%10d'\n", intValue);
    printf("Left-aligned (%%-10d): '%-10d'\n", intValue);
    printf("Precision (%%0.2f): %0.2f\n", doubleValue);
    printf("Width and precision (%%8.2f): '%8.2f'\n", doubleValue);
    printf("Zero-padded (%%05d): %05d\n", intValue);

    return 0;
}

Output

Integer (%d): 42
Float/Double (%f): 3.141590
Character (%c): A
String (%s): Hello
Hexadecimal (%x): ff
Pointer (%p): 0x7ffeeb3a1b0c (this address will vary)

--- Formatting Examples ---
Right-aligned (%10d): '        42'
Left-aligned (%-10d): '42        '
Precision (%0.2f): 3.14
Width and precision (%8.2f): '    3.14'
Zero-padded (%05d): 00042
相关标签
About Me
XD
Goals determine what you are going to be.
Category
标签云
Linux Docker FlashAttention Sklearn 顶会 Claude 公式 GoogLeNet Markdown IndexTTS2 RL 报税 VGG-16 Bitcoin mmap Ubuntu Git 搞笑 uWSGI Image2Text CAM Dataset Permission GGML Streamlit Transformers Input Color tar Use Tiktoken ModelScope Agent Paper printf ms-swift Plate Pickle FastAPI Card Magnet Conda Firewall JSON Hilton SAM Translation Zip diffusers Template SQL 递归学习法 PIP AI llama.cpp Heatmap v0.dev 图标 云服务器 XML Django Website Nginx DeepStream PyCharm Qwen2.5 Food OpenCV Bipartite 音频 版权 Diagram BTC Qwen tqdm 证件照 NameSilo Animate 域名 HaggingFace GPTQ PyTorch Freesound Video OCR Miniforge RAR hf NLTK FP32 Plotly git Anaconda Vmess 飞书 Jetson Augmentation icon BF16 Datetime GIT 算法题 Github Excel Domain 图形思考法 torchinfo git-lfs ResNet-50 Search Random 强化学习 Google Disk Cloudreve 多进程 GPT4 COCO Hungarian 净利润 Paddle FP8 TensorFlow 继承 RGB NLP VSCode 论文速读 Data XGBoost UI 多线程 Pillow Base64 FP16 QWEN WebCrawler Review FP64 Mixtral Tensor Clash CLAP BeautifulSoup HuggingFace ChatGPT Baidu Bert CTC Logo Michelin Python CSV Knowledge Proxy Quantize CEIR Algorithm VPN Shortcut logger Land 关于博主 LLM LLAMA 签证 Llama ONNX Tracking 第一性原理 Breakpoint Interview transformers Gemma LeetCode v2ray 阿里云 PDF Password EXCEL MD5 UNIX Statistics API CC Jupyter 腾讯云 Crawler Numpy SQLite News Pandas LoRA Safetensors Bin Hotel TTS WAN uwsgi TensorRT YOLO scipy Math Vim 财报 Ptyhon InvalidArgumentError Attention Quantization Rebuttal PDB Qwen2 SVR TSV CUDA CV DeepSeek Pytorch C++ Windows Web Distillation OpenAI SPIE 论文 LaTeX
站点统计

本站现有博文333篇,共被浏览922112

本站已经建立2628天!

热门文章
文章归档
回到顶部