1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "input3.h"
#include "input3.c"
/* Die Konstanten:
* int MAX_LAENGE_STR - die maximale String Länge
* int MAX_LAENGE_ARR - die maximale Array Länge
* sind input3.c auf jeweils 255 und 100 definiert
*/
int main(int argc, char **argv) {
//int main(){
/* if (argc < 3) {
printf("Aufruf: %s <anzahl> <bundesland>\n", argv[0]);
printf("Beispiel: %s 100 Bayern\n", argv[0]);
printf("Klein-/Großschreibung beachten!\n");
} */
//int anzahl = atoi(argv[1]);
//char *bundesland = argv[2];
int anzahl = 110000;
char *bundesland = "Bayern";
char staedte[100][255];
char laender[100][255];
int bewohner[100];
int o=0;
int len = read_file("staedte.csv", staedte, laender, bewohner);
char *erg =(char*)malloc (len*(sizeof(char)));
char* result[10];
for(int i = 0;i<len;i++){
if (strcmp(laender[i], bundesland)==0 ){
sprintf(erg,"Die Stadt '%s' hat '%d' Einwohner\n", staedte[i], bewohner[i]);
result[o]=erg;
o++;
}
}
write_file(result, 10);
}
|