#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);
}
上記のコードをコンパイルして、10進数を別の基数に変換できるかどうかを確認しようとしましたが、次のエラーが発生します。
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 ==========