Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main(int argc, char **argv) {
- if (argc < 3) {
- printf("Aufruf: %s <anzahl> <bundesland>n", argv[0]);
- printf("Beispiel: %s 100 Bayernn", argv[0]);
- printf("Klein-/Großschreibung beachten!n");
- exit(1);
- }
- int anzahl = atoi(argv[1]);
- char *bundesland = argv[2];
- // Statisch allokierter Speicher
- char staedte[MAX_LAENGE_ARR][MAX_LAENGE_STR];
- char laender[MAX_LAENGE_ARR][MAX_LAENGE_STR];
- int bewohner[MAX_LAENGE_ARR];
- int len = read_file("staedte.csv", staedte, laender, bewohner);
- // Hier implementieren
- int x=0;
- int d=0;
- //int b=0;
- //char* zeile_array=(char*) malloc (len * sizeof(char));
- char *zeile_array[50];
- char *zeile;
- zeile=(char*) malloc(100); //allocating memory
- for(x=0;x<len;x++)
- {
- if(strcmp(laender[x],bundesland) == 0 && bewohner[x] >= anzahl)
- {
- sprintf(zeile, "Die Stadt %p hat %d Einwohner.",staedte[x],bewohner[x]);
- zeile_array[d]=zeile; // putting it into array
- d=d+1;
- }
- }
- //b++;
- }
- write_file(zeile_array,d);
- free(zeile);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement