Search:

Type: Posts; User: shadow1515

Search: Search took 0.01 seconds.

  1. Problem using 'if' statment to exclude characters in an array

    In the folllowing code, I have an array of characters called 'data', and I want to scan through it and write characters to a file ONLY if they are not a digit or a space. I can't get this to happen;...
  2. I got it working by rellocating to t *...

    I got it working by rellocating to t * sizeof(int) for t that increases each time the loop executes to add more to the array.

    Thanks for the help, the problem was that I didn't realize exactly...
  3. Since this code already takes place in a loop...

    Since this code already takes place in a loop with a variable that counts up with each loop, would it be correct to use



    num1 = realloc(num1, t * sizeof(int));


    since t is growing by one...
  4. Question about dyamic allocation of memory

    Basically, I've got two pointers that I want to fill with data read from a file, and I want my program to allocate memory to the pointers based on how much data there is (since it will not always be...
  5. It does, thank you, you did a lot to clear up my...

    It does, thank you, you did a lot to clear up my understanding of structures and pointers.
  6. Thanks for the information. I think I'm starting...

    Thanks for the information. I think I'm starting to understand a little better now. I ended up simply declaring the position array as int position[2] because I already knew what size I wanted it to...
  7. As far as I'm aware, there is no more allocation...

    As far as I'm aware, there is no more allocation code. I don't even know enough to know what that really means. To show more code, here is how I use the first structure element that works:


    ...
  8. Problem using structures (they crash my program)

    I'm just learning structures, and I'm having some trouble. The following is the structure I delcared globally:


    struct creatures
    {
    int *position;
    };

    and the next is when I declare members...
  9. Replies
    2
    Views
    1,302

    Thanks, that did it. I figured fscanf wouldn't...

    Thanks, that did it. I figured fscanf wouldn't do it, but I didn't know about sprintf.
  10. Replies
    2
    Views
    1,302

    Indexing files to write to?

    I'm writing a program and I want to put a written file inside a for loop. For each run through the loop, I want to write to a different file. How do I do this? Here's the code:


    ...
  11. Replies
    2
    Views
    1,862

    Updating display on screen?

    I wrote a simple program to print a grid of 0s on the screen, and move a 1 around with user input from the keyboard (eventually, the goal is a "snake" game).

    It works fine. I hit W, it moves the...
  12. Replies
    8
    Views
    6,231

    Oh, now that I've already posted my entire code,...

    Oh, now that I've already posted my entire code, I'm having another issue and I don't quite know how to resolve it. After adding getchar after the scanf in my ask function, it works fine. Another...
  13. Replies
    8
    Views
    6,231

    Ok, adding getchar right after my scanf made it...

    Ok, adding getchar right after my scanf made it work fine. Thanks for your help!
  14. Replies
    8
    Views
    6,231

    Ok, here's my entire program. It runs perfectly...

    Ok, here's my entire program. It runs perfectly fine besides automatically closing after it runs, but if you have any other suggestions those would be greatly appreciated as well.


    #include...
  15. Replies
    8
    Views
    6,231

    Using getchar to keep program running

    In the beginner tutorial on this site, it mentioned that adding the line getchar(); right before return 0; at the end of the main function would keep the program running until the user hit enter.
    ...
Results 1 to 15 of 15