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

本站现有博文341篇,共被浏览1041114次

本站已经建立2726天!

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