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

本站现有博文316篇,共被浏览747399

本站已经建立2396天!

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