编译一个“约分分数为最简分式”程序时遇到 error: expected “)” before “&” token
代码如下:
代码如下:
#include <stdio.h> /* prototype */ void reduce(int numerator, int denominator, int *reduced_numerator, int *reduced_denominator); int main(void) { int m, n, reduced_m, reduced_n; printf("Enter a fraction: "); scanf("%d/%d", &m, &n); void reduce(m, n, &reduced_m, &reduced_n); //错误显示在这行 printf("In lowest terms: %d/%d\n", reduced_m, reduced_n); return 0; } void reduce(int numerator, int denominator, int *reduced_numerator, int *reduced_denominator) { int mod, m, n; m = numerator; n = denominator; while (n != 0) { mod = m % n; m = n; n = mod; } *reduced_numerator = numerator / m; *reduced_denominator = denominator / m; }
解决方案
40
第14行, 函数调用,去掉前面的函数返回值类型void