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

本站现有博文332篇,共被浏览875392

本站已经建立2583天!

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