c - MacOS 终端与 Xcode 中的不同输出(C 程序)

标签 c xcode terminal output

终端与 Xcode 存在输出问题。感谢任何能告诉我我做错了什么的人。

简单的程序:

/* Military officer: age, rank, serial number, base pay, and number of years in service */

 #include < stdio.h>

int main()

{

int age, rank, ss1, ss2, ss3;

float base_pay, years;

    /* Ask User to Input Various Entries */

    printf("Enter officer age: ");
    scanf("%d", &age);

    printf("Enter officer rank (e.g. 3 for captain): ");
    scanf("%d", &rank);

    printf("Enter serial number (e.g. 000-00-0000): ");
    scanf("%d -%d -%d", &ss1, &ss2, &ss3);

    printf("Enter base pay: ");
    scanf("%f", &base_pay);

    printf("Enter number of years in service: ");
    scanf("%f", &years);

    /* Output of Entries */

    printf("\nOfficer\t\t\tOfficer\t\t\tSerial\t\t\tBase\t\tYears\n");
    printf("Age\t\t\tRank\t\t\tNumber\t\t\tPay\t\tin\n");
    printf("\t\t\t\t\t\t\t\t\t(USD)\t\tService\n\n");
    printf("=======\t\t\t=======\t\t\t===========\t\t=========\t=======\n\n");

    printf("%-d\t\t\tO-%-d\t\t\t%-.3d-%.2d-%.4d\t\t$%-.2f\t%-10.1f\n\n", age, rank, ss1, ss2, ss3, base_pay, years);

    return 0;
}

Terminal Output

XCode Output

最佳答案

它们之间的“\t”行为可能不同。

关于c - MacOS 终端与 Xcode 中的不同输出(C 程序),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45024977/

相关文章:

c++ - 如何提取两个括号之间的字符串?

java - JNI native 调用 *prototypes* 在他们自己的类/ namespace ?

c - 如何在没有 x-macros 的情况下在 C 中获得类似反射的功能

objective-c - 链接到 Cocoa/Xcode 中的常量文件

c - 使用 C 打印行而不覆盖尚未在终端中提交的用户输入

c - 如何查看一个detached属性的线程退出后是否释放了系统资源?

缩小到主页过渡动画期间的 iOS 应用程序图标背景颜色

iphone - Apple Mach-O Linker错误Xcode

SQLite3 终端输出格式 .width

python - 我如何决定在 mac 终端中打开哪个 python?