#include <stdio.h>
#include <math.h>
long int input;
long int base, exponent;
void convert(long int x,long int y)
{
input = x;
base = y;
while (input > 0){
exponent = floor(log(input)/log(base));
input = input - pow(base, exponent);
}
}
int main(void){
scanf("%d", &input);
scanf("%d", &base);
convert(input, base);
}
我试图编译上面的代码以查看是否可以将十进制转换为不同的基数,但出现以下错误:
assignment2.c(14): error C2143: syntax error : missing ';' before 'type'
我已经挣扎了几个小时,但我不知道这是指什么。我怎样才能解决这个问题?
编辑:这是整个信息
1>------ Build started: Project: assignment2, Configuration: Debug Win32 ------
1>Build started 2012-04-27 오후 5:45:10.
1>InitializeBuildStatus:
1> Touching "Debug\assignment2.unsuccessfulbuild".
1>ClCompile:
1> assignment2.c
1>c:\users\조화수\documents\visual studio 2010\projects\assignment2\assignment2\assignment2.c(14): error C2143: syntax error : missing ';' before 'type'
1> assign2.c
1>c:\users\조화수\documents\visual studio 2010\projects\assignment2\assignment2\assign2.c(13): warning C4244: '=' : conversion from 'double' to 'long', possible loss of data
1>c:\users\조화수\documents\visual studio 2010\projects\assignment2\assignment2\assign2.c(14): warning C4244: '=' : conversion from 'double' to 'long', possible loss of data
1>c:\users\조화수\documents\visual studio 2010\projects\assignment2\assignment2\assign2.c(19): warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio 10.0\vc\include\stdio.h(304) : see declaration of 'scanf'
1>c:\users\조화수\documents\visual studio 2010\projects\assignment2\assignment2\assign2.c(20): warning C4996: 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files\microsoft visual studio 10.0\vc\include\stdio.h(304) : see declaration of 'scanf'
1> Generating Code...
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:02.98
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========