Counting characters in a buffer
-
Ok im trying to count the characters that i have loaded into a buffer i have set up the following function void countchars(char *buffer, int *count) /*Counts the number of characters in the text file */ { int i,counter; char cdata; count['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']; do { { for(cdata='A';cdata<='Z';cdata++) if(buffer[i]==counter[count]) { count++; } i++; } }while(buffer[i]!=EOF); } I am calling this function using the following code: countchars(buffer,cdata); printf("\nDistribution of letters in %s is:",fname); for (c='A';c<='Z';c++) { N=cdata[c]+cdata[tolower(c)]; printf("\n'%c' %4d: ",c,N); for (i=0;i
-
Ok im trying to count the characters that i have loaded into a buffer i have set up the following function void countchars(char *buffer, int *count) /*Counts the number of characters in the text file */ { int i,counter; char cdata; count['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']; do { { for(cdata='A';cdata<='Z';cdata++) if(buffer[i]==counter[count]) { count++; } i++; } }while(buffer[i]!=EOF); } I am calling this function using the following code: countchars(buffer,cdata); printf("\nDistribution of letters in %s is:",fname); for (c='A';c<='Z';c++) { N=cdata[c]+cdata[tolower(c)]; printf("\n'%c' %4d: ",c,N); for (i=0;i
You might want to post this in a C/C++ board. The code above isn't C# style.
R.Bischoff | C++ .NET, Kommst du mit?