Thread: Help!!!!

  1. #16
    Registered User
    Join Date
    Nov 2008
    Posts
    33
    Quote Originally Posted by starvinmarvin View Post
    thanks for all the help so far...now when i go to report the numbers and characters some of the frequencies are addresses instead of the frequency of the number....
    Which ones?

  2. #17
    Registered User
    Join Date
    Oct 2008
    Posts
    55
    You have to zero out arr before accumulating your counts.

  3. #18
    Registered User
    Join Date
    Oct 2008
    Posts
    46
    how to i do that

  4. #19
    Registered User
    Join Date
    Oct 2008
    Posts
    46
    actually i thought i already did that by arr[i-32]???

  5. #20
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Code:
    memset(arr, 0, sizeof(arr));

  6. #21
    Registered User
    Join Date
    Oct 2008
    Posts
    46
    i tried to put that at the begging and end of the count and it didnt work

  7. #22
    Registered User
    Join Date
    Nov 2008
    Posts
    33
    Is memset a function like fileopen? If it is, is there a different function we can use besides memset, like fileopen?

  8. #23
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    @TMK: There is no function fileopen. If you mean fopen, then yes, memset is a built in function (in <string.h>, for whatever reason).

    @marvin: You wouldn't want to reset at the end -- you'd just undo all the work that you just did.

  9. #24
    Registered User
    Join Date
    Nov 2008
    Posts
    33
    Quote Originally Posted by tabstop View Post
    @TMK: There is no function fileopen. If you mean fopen, then yes, memset is a built in function (in <string.h>, for whatever reason).

    @marvin: You wouldn't want to reset at the end -- you'd just undo all the work that you just did.
    Yes I meant fopen. Is there a way around using memset like using fopen?

  10. #25
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by The Monkey King View Post
    Yes I meant fopen. Is there a way around using memset like using fopen?
    I think you are under the impression that that sentence means something. Regrettably, it does not. Obviously fopen and memset are completely different things (one opens a file on disk, the other sets a piece of memory to 0), so you can't substitute one for another. Nor is there a way around using fopen that I can see (certainly not in this program), apart from using OS-specific file functions.

  11. #26
    Registered User
    Join Date
    Oct 2008
    Posts
    46
    all i want to know is why when i print out the characters frequecys i get addresses instead of the actual frequency. i zeroed out the array with arr[i-32] but i still dont understand why i get addressses for about 32 of them

  12. #27
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by starvinmarvin View Post
    all i want to know is why when i print out the characters frequecys i get addresses instead of the actual frequency.
    Because you don't. You get "random uninitialized data plus my count", which for all intents and purposes is indistinguishable from "random uninitialized data".
    i zeroed out the array with arr[i-32]
    There is nothing in that statement that could possibly zero out an array. Now if you started by saying arr[i-32] =0, then you'd be zeroing out an array. And note that you want to do that for every possible i, before you start counting.

  13. #28
    Registered User
    Join Date
    Oct 2008
    Posts
    46
    well i am gettting like huge numbers that are suppose to be in the array where i am looking and printing so i assume that it is addresses....maybe not...look at the code and tell me what i am doing wrong..

  14. #29
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by starvinmarvin View Post
    well i am gettting like huge numbers that are suppose to be in the array where i am looking and printing so i assume that it is addresses....maybe not...look at the code and tell me what i am doing wrong..
    You've been given it in English and given it in code, I'm not sure what else there is, but let's try both:
    Code:
    {
     
       int arr[95] = {0}; /*Make sure that all the elements of the array are 0 */
       int num1, num2;
       bool success;      
       FILE *pFPOut;
       FILE *pFPIn;

  15. #30
    Registered User
    Join Date
    Oct 2008
    Posts
    46
    i get a compile error when i equate it to zero....invalid initializer

Popular pages Recent additions subscribe to a feed