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

本站现有博文338篇,共被浏览988876次

本站已经建立2701天!

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