I am trying to read a text file and getting all sorts of problems reading it. It dont seem to put anything in the string.
Here is my CODE
#include "DarkGDK.h";
#include "EZrotate.h";
#include "string.h";
#include "windows.h";
const int maxplants=100;
int loadobjectmap(char* continent){
char planttemp[10]="";
char temp[20]="";
char file[20]="";
int plantcount;
strcpy(file,"Objectmaps\\");strcat(file,continent);strcat(file,"plantmap.txt");
dbSetDir("C:\\Program Files\\The Game Creators\\Dark GDK - FREEWARE Edition\\Projects\\KillerScuds\\KillerScuds");
//dbOpenToRead(1,"Objectmaps\\Australiaplantmap.txt");
dbPrint(file);
dbOpenToRead(1,file);
dbReadString(1,temp);
dbPrint(temp);
dbReadString(1,planttemp);
dbPrint(planttemp);
plantcount=dbVal(planttemp);
dbPrint(dbStr(plantcount));
//int plants[plantcount][3];
int plants[maxplants][3];
for (int t = 1;(t<plantcount && t<maxplants);t++){
dbReadString(1,planttemp);plants[t][0]=dbVal(planttemp);
dbPrint(dbStr(plants[t][0]));
dbReadString(1,planttemp);plants[t][1]=dbVal(planttemp);
dbPrint(dbStr(plants[t][1]));
dbReadString(1,planttemp);plants[t][2]=dbVal(planttemp);
dbPrint(dbStr(plants[t][2]));
}
dbCloseFile(1);
return plantcount;
}
void DarkGDK ( void )
{
char continent[11]="Australia";
dbSetWindowOn();
dbSetDisplayMode(800,600,32);
int plantcount;
plantcount=loadobjectmap(continent);
while (!dbEscapeKey()){
dbSync();
}
}
and here is the text
Australia
45
804
1164
1
908
1164
1
1040
1156
1
1168
1108
1
852
1136
1
960
1128
1
1084
1112
1
776
1104
2
900
1100
2
1000
1092
2
1132
1076
2
1096
1028
2
972
1044
2
864
1064
2
760
1076
2
732
1036
3
800
1040
3
880
1020
3
964
1012
3
1036
1000
3
1112
988
3
1088
940
3
980
956
3
904
964
3
820
992
3
744
996
3
724
972
4
800
940
4
888
920
4
972
908
4
928
864
4
824
896
4
744
916
4
692
948
4
672
876
5
756
852
5
840
840
5
928
800
5
848
776
5
752
796
5
676
824
5
632
844
5
1244
1060
6
1212
960
6
1176
856
6
0
0
0
If you look at the output you will see that i am getting a wrong value for the temp value it is returning plantmap.txt when it should be returning Australia. I dont even know where its getting its value from and everything else is not read. It is a really small file so it wont take long to check
fubar