error C2109: subscript requires array or pointer type
-
with other words:
int i=1;
char *a;
int b, c, d, e;
FILE * file = fopen("coord.txt", "r");
while(!feof(file))
{
fscanf(file, "%s%d%d%d%d", &a, &b, &c, &d, &e);
if(strcmp(&a[0],fileName)==1)ist das so ok?
-
Du deklarierst einen Pointer mit dem Type char, und beim einlesen benutzt du den Adressoperator, der Pointer beiinhaltet doch schon die Adresse!!!
-
also so?
char *a;
int b=0; int c=0; int d=0; int e=0;
FILE * file = fopen("coord.txt", "r");
while(!feof(file))
{
fscanf(file, "%s%d%d%d%d", a, &b, &c, &d, &e);meldet auch nen fehler...
-
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char *fileName; fileName = "000.png"; int i=1; char *a; int b, c, d, e; FILE * file = fopen("coord.txt", "r"); while(!feof(file)) { fscanf(file, "%s%d%d%d%d", a, &b, &c, &d, &e); if(strcmp(a,fileName)==1) { //eyeL.x=b; break; } i++; } system("PAUSE"); return 0; }
schaus dir genau an, leider wusste ich nicht wo du dein structure versteckt hast... aber eyeL kannst ja wieder seten...
-
danke!
jetzt zeigt er beim rennen lassen "Run-Time Check Failure #3 - The variable 'a' is being used without being initialized."
-
deklariers ma als array...
Grüße
agi
-
biiiitte, lös das rätsel auf. hab echt schon ALLE varianten durch
und ich sollt ein demo für morgen vorbereiten und ich häng an dem scheiss schon seit mind. 1h
-
probiers ma damit:
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char *fileName; fileName = "test.txt"; int i=1; char *a; int b, c, d, e; FILE * file = fopen("coord.txt", "r"); while(file!=NULL) { fscanf(file, "%s %d %d %d %d", a, &b, &c, &d, &e); if(strcmp(a,fileName)==1) { //eyeL.x=b; break; } i++; } system("PAUSE"); return 0; }
Grüße
agi
-
wo ist der unterschied zu dem obigen?
char *a; //geblieben
und in der if-anweisung ists ohne '&'
also wo kommt das deklarieren als array?danke, dass du hilfst!
-
ann1025 schrieb:
also wo kommt das deklarieren als array?
Das brauchst dz wohl nicht, wenn du Pointer einsetzt.
wo ist der unterschied zu dem obigen?
while(file!=NULL)
-
Run-Time Check Failure #3 - The variable 'a' is being used without being initialized.
-
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char *fileName; fileName = "test.txt"; int i=1; char a[100]; int b, c, d, e; FILE * file = fopen("coord.txt", "r"); while(file!=NULL) { fscanf(file, "%99s %d %d %d %d", a, &b, &c, &d, &e); if(strcmp(a,fileName)==1) { //eyeL.x=b; break; } i++; } system("PAUSE"); return 0; }
Also, wenn das nicht geht dann weis ich leider auch nicht weiter...
-
irgendwas mit strcmp passt nicht, weil der rennt durch
-
ann1025 schrieb:
irgendwas mit strcmp passt nicht, weil der rennt durch
achso du willst das der index stets erhöht wird oder`? machs doch mit for...
oder etw. anderes...
edit:
aso, er rennt durch dann is irwas an der if bedingung...
-
Poste mal den gesamten Code nicht nur das Fragment.
-
eeeeeeeeeeeeeeeendlich
unglaublich:
char *fileName;
CvPoint eyeL;
CvPoint eyeR;fileName = "s2.png";
//fileName = "seq_000541.png";
// fileName = "seq_000700.png";
int i=1;
char a[20];
int b=0; int c=0; int d=0; int e=0;
FILE * file = fopen("coord.txt", "r");
while(!feof(file))
{
fscanf(file, "%s %d %d %d %d", a, &b, &c, &d, &e);
if(strcmp(a,fileName)==0)
{
eyeL.x=b;
eyeL.y=c;
eyeR.x=d;
eyeR.y=e;
break;
}
i++;}
-
ann1025 schrieb:
eeeeeeeeeeeeeeeendlich
unglaublich:Funzt es etwa
Gruß
agi