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

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

本站已经建立2590天!

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