Can you help me with multiple errors in C? -
I'm quite new to C and I'm having difficulty in some different concepts, including pointers, arrays, and reading Files My program has started here, I am sure that these are some errors, can you show me what I am doing wrong? The program is supposed to read the letters from congress.txt and read them as capital letters without spaces, I also tried to do a little test which will print the letter for me so that I can see that the characters in the array store Are right. I have heard that I should not take the exam! = Eof before here, but my teacher has used it and I do not want to copy some things which I do not understand.
This is Congress.txt:
Congress will not make any law regarding the establishment of religion, or will restrict free exercise; Or suppress the speech, or freedom of the press; Or the right to collect people peacefully, and to petition the government for redressal of grievances.
# include & lt; Stdio.h & gt; Int Processfile (Int * Store); Int cipher (int * store, int * code); Int main (empty) {int store [300], code [300], I; processFile (store); (I = 0; Store [i]! = 0; ++ i) {// stores a print test so I can see that the text was printed properly printf ("% c", store [ I]); } By (); Return; } Int processFile (int * store) {int i, a = 0; FILE * f = fopen ("congress.txt", "r"); For (i = 0; a! = EOF;) {fscanf (f, "% c", and one); // Character in a store (a & lt; = 'Z' & A & gt; = 'A') {// store capital letter store [i] = A; I ++; } If (a & lt; = 'z' & a & gt; = 'a') {// low case store as low case letter [i] = a - 32; I ++; }}}}
This loop does not mean any kind. For the
(i = 0; b! = NULL; i ++) printf ("% s", store [i]); B = store [i + 1]; } store [i] is a int , so that you can call it "% s" . I think you mean printf ("% c", store [i]); which means printing of characters whose character code is int (which is okay because you first got it scanf ). b! = Null should be b! = 0 , but this code for the first time around the loop try it instead: for (i = 0; store [i ]! = 0; ++ i) printf ("% c", store [i]); In the second part of the code, 65 , 90 , 97 , 122 expressly expressed as 'A' , 'Z' , 'a' , 'z' She goes. Respectively You can see the isupper , isholar function from & lt; ctype.h & gt; . a-32 to toupper (a); .
Comments
Post a Comment