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

本站现有博文333篇,共被浏览928548

本站已经建立2636天!

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