On a hunch, I'd tell you that the initialiser is used to initialise, not assign.i get a compile error when i equate it to zero....invalid initializer
On a hunch, I'd tell you that the initialiser is used to initialise, not assign.i get a compile error when i equate it to zero....invalid initializer
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
ok well i tried the == to assign it to zero..that didnt work either..
That's equality comparison, not assignment.Originally Posted by starvinmarvin
What exactly did you try, and how exactly does it not work?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
ok it should say like
'A' 5
'B' 6
a being the character and the number being how many times it was found it the random data generated. i save it in an array. but then when i go to print it out i get like
'O' -17073743537
'4' 24641436
it looks like an adresse and there are about 32 so i think i am just not setting the array up correctly like i am missing something
There is a problem with your code. I think you are doing something wrong. You should fix it.
That's very helpful, isn't it? Likewise, if you want help from us, you need to give us something to work with.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
the code for the whole program is on the first page of this thread
And 37 posts later you have made no changes to it at all, despite claiming that you tried some suggestions?Originally Posted by starvinmarvin
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Yes. Well. If you won't take any of the twenty-two previous suggestions, why should we give you a twenty-third? You say the one I posted last doesn't work. I KNOW it works, because I am typing this on my very own computer upon which I can compile things. So show us what you tried to do to fix this, because we have suggested fixes. The fact that you say they don't work just means that you have done something weird to them.
whats wrong with thisCode:int generate(int arr[], int num1, int num2, FILE *pFPOut) { int linesize = 75; int numprinted = 0; int i; int temp; printf("The data in test.txt is %d %d.", num1, num2); printf("\n"); printf("\n"); srand(num1); for (i = 0; i < num2; i++) { temp = rand() % 95 + 32; fprintf(pFPOut,"%c", temp); printf("%c", temp); arr[temp-32]++; numprinted++; if (numprinted >= linesize) { fprintf(pFPOut,"\n"); printf("\n"); numprinted = 0; } } printf("\n\n"); return ; } //print report to screen void report(int arr[], FILE *pFPOut) { int numprinted = 0; int i; int linesize = 4; fprintf(pFPOut,"\n\n"); for (i = 32; i < 126; i++) { numprinted++; fprintf(pFPOut,"'%c' %5d", i, arr[i-32]); printf("'%c' %5d", i, arr[i-32]); { printf(" "); fprintf(pFPOut," "); } if (numprinted >= linesize) { printf("\n"); fprintf(pFPOut,"\n"); numprinted = 0; } } printf("\n\n"); return ; }
ok i was able to put arr[95] = 0 below where i delcared it and i still get a bunch a crazy numbers.
dude just tell me what i need to write to get it to print the frequency..im tired of working on this