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

本站现有博文340篇,共被浏览1027094次

本站已经建立2721天!

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