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

本站现有博文336篇,共被浏览946930

本站已经建立2657天!

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