私のCプログラムでは本当にイライラしています。参照渡し、異なる基底型のエラー
エラーがある:
main.c(65): error C2371: 'extractVals' : redefinition; different basic types
directClassは、変数sを用いて(スイッチケースに「G」)20、具体的ライン、文字への参照を受け入れるように仮定されています。彼らはどのように同じ基本的なタイプではないが、私は非常に良いCではないので、私はすべての問題を識別する上ではそれほどイムではないかわかりません。どんな助けも素晴らしいだろう。
#include <gl\glew.h>
#include <gl\freeglut.h>
#include <gl\GLU.h>
#include <stdio.h>
void directFile(char input[100]){
char switchVal [10] , *s = switchVal;
float val1, val2, val3, val4;
s = strtok(input, " \n\0");
printf("Told str is %s\n", s);
switch(*s){
case '#':
printf("%s is a comment. Has no bearing on application\n", s);
break;
case 'g':
printf("%s is the command to translate an object!\n", s);
extractVals(s);
break;
case 's':
printf("%s is the command to scale, now which one is it?\n",s);
break;
case 'r':
printf("%s will rotate the image!\n",s);
break;
case 'c':
if(strcmp(s , "cone") == 0){
printf("It appears you have your self a %s\n", s);
} else if (strcmp(s , "cube") == 0){
printf("%s is cool too\n" , s);
} else if (*s == 'c'){
printf("Welp command was \"%s\", lets change some colors huh?\n",s);
}
break;
case 't':
break;
case 'o':
break;
case 'f':
break;
case 'm':
break;
}
}
void extractVals(char *input){
while(input != NULL){
printf("%s\n", input);
input = strtok(NULL, " ,");
}
}
void makeLower(char *input)
{
while (*input != '\0')
{
*input = tolower(*input);
input++;
}
}
int main(int argc, char *argv[]) {
FILE *file = fopen(argv[1], "r");
char linebyline [50], *lineStr = linebyline;
char test;
glutInit(&argc, argv);
while(!feof(file) && file != NULL){
fgets(lineStr , 50, file);
makeLower(lineStr);
printf("%s",lineStr);
directFile(lineStr);
}
fclose(file);
glutMainLoop();
}
再定義エラーが奇妙である与えている理由の一番上にある関数のプロトタイプを追加すること
いずれかの方法を試して、それはのようなエラーに何かを与える必要があります。関数が実際に宣言される前に関数を呼び出しています。 –
Cは参照渡しをサポートしていませんが、C++は参照渡しをサポートしていません。 Cはポインタを使用します。 http://en.wikipedia.org/wiki/Evaluation_strategy#Call_by_reference –