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

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

本站已经建立2583天!

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