Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道您是否可以执行以下操作:
printf("\nEnter kwh used (for 7 economy tariff, enter Peak usage)\n"); scanf("%d",&kwh,&peak);
我想它不会起作用,但有什么办法可以获得类似的效果。我希望你知道我的意思。我正在尝试从一个 scanf 中获取一个(峰值或 kwh),以便以后可以将其传递给适当的函数。
如果您希望两个变量中的值相同,您应该自己执行此操作:
int kwh, peak; if (scanf("%d",&kwh) == 1) { peak = kwh; } else { // complain }