Crashing problem(probably loop)

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
54
55
56
57
#include <iostream>
#include <stdio.h>
#include <conio.h>
#include <string.h>


int main()
{

    FILE *fp,*fpp;
    char bla[200][40];
    char abi[2000] = "";
    int koht=0,i=0,j=0;
    char mark;
    fp = fopen("Teaduskond.txt","r");
    fpp = fopen("Storage.txt","w");
    while(!feof(fp)){                       //do until the end of file
        fgets(abi,200,fp);                  // get a line
        koht=0;mark=abi[koht];
        do{                                 //check each char
            mark=abi[koht++];
            switch(mark){
                case '.': fprintf(fpp," ");break;  // ASCII does not like the
                case 'ü': fprintf(fpp,"u");break;  // Estonian alphabet letters
                case 'õ': fprintf(fpp,"o");break;
                case 'ä': fprintf(fpp,"a");break;
                case 'ö': fprintf(fpp,"o");break;
            }
            if(isalnum(mark)){ 
                fputc(mark,fpp);
            }
            if(isspace(mark)){
                fputc(mark,fpp);
            }
        }while(mark);                            //end of row
    }                                           //end of file
    fclose(fp);
    fclose(fpp);
    fpp = fopen("Storage.txt","r");
    while(!feof(fpp)){          // go through the cleaned(words and spaces) file
        fgets(abi,200,fpp);
        koht=0;mark=abi[koht];
        do{                         
            mark=abi[koht++];
            bla[i][j]=mark;
            j++;
            if(isspace(mark)){
                i++;
                continue;
            }
        }while(mark); 
    }                   
    fclose(fpp);
    printf("\n\nHit something...");
    getch();
    return 0;
}


I need to clean the first file and then store individual words. I use a second file to store the "clean" version of the the text that does not have any ".",","")" and so on(special characters). When I run it, it simply crashes.
I probably use memory in an incorrect way or there is something wornf with the second while or do loop. Please do not critizise that I use 2 files.Any help is appreciated.
closed account (Dy7SLyTq)
if ur using c++ why not use the abstractions? ie fstream string and vector?
Well because, I am taking an Intro to C++ class and we will not cover that in this course, so I tried to do it this way instead of copying some code that I do not understand or I would have had to learn about many many things to do it in some actually easy built in way, because I have to be able to explain everything to my teacher.
closed account (Dy7SLyTq)
well, i dont want to be that guy, but your actually writing c code... but anyways which while loop is it crashing in
the first loop I guess
Topic archived. No new replies allowed.