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

本站现有博文337篇,共被浏览961702次

本站已经建立2673天!

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