打印#defined’d常数

打印#defined’d常数,第1张

概述#include<stdio.h>#define UPPER 999999#define LOWER 11111int main(void){// Local Declarationsdouble price = 89.99;char grade = 'B';int age = 97;// Statementsprintf("Homework 2:\n\nUs
#include<stdio.h>#define UPPER   999999#define LOWER   11111int main(voID){//  Local Declarationsdouble price = 89.99;char grade = 'B';int age = 97;//  Statementsprintf("Homework 2:\n\nUsing printf\n");printf("  age = %c,age\n");printf("grade = %d,grade\n");printf("price = %f,price\n\n");printf("Using both printf and scanf\n");printf("Enter a new value for age: ");scanf("%d",&age);printf("Enter a new value for grade: ");scanf("%c",&grade);printf("Enter a new value for price: ");scanf("%lf",&price);printf("Print the new values\n");printf("  age = %d \n",age);printf("grade = %c\n",grade);printf("price = %lf\n\n",price);print("\n\nPrinting two defined constants: "UPPER" and "LOWER"\n");print("UPPER = %08d\n",UPPER);print("LOWER = %08d\n",LOWER);return 0;}   //  end of main

以上是我的程序,我应该修复它.我已经待了将近3个小时,现在仍然可以找出问题所在.我有一个错误和一些警告.

warning: too few arguments for format

中间声明的几个警告

error: expected ')' before numeric constant

此错误用于打印两个常量.

解决方法 你需要把你的printf args放在引号之外.

当前:

//  Statementsprintf("Homework 2:\n\nUsing printf\n");printf("  age = %c,price\n\n");

应该:

//  Statementsprintf("Homework 2:\n\nUsing printf\n");printf("  age = %c\n",age);printf("grade = %d\n",grade);printf("price = %f\n\n",price);
总结

以上是内存溢出为你收集整理的打印#defined’d常数全部内容,希望文章能够帮你解决打印#defined’d常数所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1220948.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-05
下一篇 2022-06-05

发表评论

登录后才能评论

评论列表(0条)

保存