Commit a1c5cda0 authored by saeed's avatar saeed
Browse files

sshval seems to work now

parent 0000f2fa
...@@ -16,29 +16,27 @@ long int numLines(FILE *FS){ ...@@ -16,29 +16,27 @@ long int numLines(FILE *FS){
int Strlen(char *sa){ int Strlen(char *sa){
int len = 0; int len = 0;
while(*sa++) len += 1; while(*sa != '\0'){
len += 1;
return len; sa++;
}
return len;
} }
int Strcmp(char *sa, char *sb){ int Strcmp(char *sa, char *sb){
if (Strlen(sa) != Strlen(sb)){ if (Strlen(sa) != Strlen(sb)){
//printf("input strings are not of the same size\n");
return 0; return 0;
} }
while ((*sa == *sb) && *sa != '\0' && *sb != '\0' ){ while ((*sa == *sb) && *sa != '\0' && *sb != '\0' ){
//printf("%c\t%c\n",*sa,*sb);
sa++; sa++;
sb++; sb++;
} }
if (*sa == '\0'){ if (*sa == '\0'){
//printf("string sa reached its end so it means that sa is equal sb\n");
return 1; return 1;
} }
else{ else{
//printf("search ended at %c\n",*sa);
return 0; return 0;
} }
} }
...@@ -62,7 +60,6 @@ int main(void){ ...@@ -62,7 +60,6 @@ int main(void){
while ((cc=fgetc(FS)) != EOF){ while ((cc=fgetc(FS)) != EOF){
if (cc != ','){ if (cc != ','){
if(cc=='\n'){ if(cc=='\n'){
//printf("=================end of line =========================\n");
nl += 1; nl += 1;
if (nl == 1) break; if (nl == 1) break;
} }
...@@ -105,17 +102,20 @@ int main(void){ ...@@ -105,17 +102,20 @@ int main(void){
} }
} }
for(int ii=0; ii < 128; ++ii) field[ii] = ' ';
//now we read date time; //now we read date time;
ne = 0; ne = 0;
int ifld = 0; int ifld = 0;
float *content = malloc(sizeof(float) *(nline -1));
nl = 0;
for (int i=0; i < nfl; ++i){ for (int i=0; i < nfl; ++i){
if (Strcmp(cfl[i],"aberdeen")){ if (Strcmp(cfl[i],"ystad_sjov")){
int ic = i; int ic = i;
printf("%d \t %s\n",i,cfl[i]); printf("%d \t %s\n",i,cfl[i]);
while ((cc=fgetc(FS)) != EOF){ while ((cc=fgetc(FS)) != EOF){
if (cc != ','){ if (cc != ','){
if(cc=='\n'){ if(cc=='\n'){
//printf("=================end of line =========================\n");
ne = 0; ne = 0;
nl += 1; nl += 1;
ifld = 0; ifld = 0;
...@@ -125,7 +125,10 @@ int main(void){ ...@@ -125,7 +125,10 @@ int main(void){
} }
} }
else{ else{
if (ic == ifld ) printf("%s\n",field); if (ic == ifld ) {
content[nl] = atof(field);
printf("%f\n",atof(field));
}
ifld += 1; ifld += 1;
ne=0; ne=0;
} }
...@@ -134,7 +137,13 @@ int main(void){ ...@@ -134,7 +137,13 @@ int main(void){
} }
fclose(FS); fclose(FS);
for(int i=0; i < (nline-1);++i){
printf("%f\n",content[i]);
}
free(cfl); free(cfl);
free(content);
return 0; return 0;
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment