Search:

Type: Posts; User: Rubik

Search: Search took 0.00 seconds.

  1. Replies
    10
    Views
    10,294

    Figuring out if address is in heap or stack

    I'm trying to code something that will print an error statement if the user tries to free something never malloc-ed (like if they try to free the address of a local variable declared on the stack).
    ...
  2. Replies
    4
    Views
    3,040

    Free without malloc

    Why can't you do something like:

    <code>
    int x;
    free(&x);
    </code>

    because technically, you are freeing what is allocated at the memory address x.
  3. Hi Salem! I'm using Ubuntu and running it on...

    Hi Salem! I'm using Ubuntu and running it on terminal.
  4. What's wrong with this code to resize a bmp file?

    Hi. I'm trying to work through Harvard's open source computer science class, and one piece of code I have to write is to resize a bmp file. I spent most of the day digesting through the code, and...
  5. Hi TheBigH! Thank you for your answer! I...

    Hi TheBigH! Thank you for your answer!

    I tried putting a while loop at the bottom inside a for-loop, but it doesn't work; here's what I did:


    printf("%i", keyword[j]);
    while (keyword[j] ==...
  6. Basic beginner loop (with arrays) does NOT work but why?

    Hi. I am frustrated with a piece of code I wrote because it malfunctions when the user inputs (command argument style) any string (keyword) with the letter a or A, and I have no idea why and I hate...
  7. ^ Can I use string array[10][4] to store 10...

    ^ Can I use
    string array[10][4] to store 10 string arrays with 4 strings in each array?

    (Like for example: string multiplestrings[10][4] = ("i love you", "hello come to me", "i don't get C";...
  8. ^ Thank you for answering. One clarification...

    ^ Thank you for answering. One clarification though: Are you basically saying that

    string multiplestrings[10][4] = ("i love you", "hello come to me", "i don't get C"; "hello world", "what are...
  9. Can strings fit in an array? (2 beginner questions)

    1. Hello! I'm new to C. I finished reading a beginning C book, and in the section about arrays, it says that one string can fit in a character array (char arrayname[]) but there cannot be a string...
  10. Program to capitalize every other word (beginning question)

    Hi! I'm trying to write a program that capitalizes every other word of a user output. (ex: if input is "i love you", the output is "i LoVe YoU").

    I am using a for loop (although an if loop might...
  11. Never mind! EVERYTHING IS RESOLVED. Thank you!

    Never mind! EVERYTHING IS RESOLVED. Thank you!
  12. Thank you for your response, Click_here! I...

    Thank you for your response, Click_here!

    I initialized the value of coins to be 0 and it works now! :) For my first code, I initialized the values too, and it works! Yahooooo!!! I'm ecstatic...
  13. Thanks, that makes more sense. However, I cannot,...

    Thanks, that makes more sense. However, I cannot, for the life of me, figure out why when I input something like 0.38, the code below doesn't work:



    #include <cs50.h>
    #include <stdio.h>
    ...
  14. c99tutorial, thanks for pointing that out! ...

    c99tutorial, thanks for pointing that out!

    However, I'm confused because
    1. When I input 0.37 (which technically should work, I get a number like 218741571). Why doesn't it work when I input...
  15. Also, about the visibility of a scope of a local...

    Also, about the visibility of a scope of a local variable,

    in the code at [C] CS50 / greedy.c - Pastebin.com , near the end when it says "printf("Here's how many coins I gave you: %d\n",...
  16. @c99tutorial: Thank you. It makes sense that...

    @c99tutorial:

    Thank you. It makes sense that you can redefine the value of a variable that has the same name as an old variable, but the reason I don't understand why this works is because in the...
  17. @click_here: Thank you for catching that! ...

    @click_here: Thank you for catching that!

    @c99tutorial and Tclausex: Thank you for answering; I have one follow-up question:

    Under my first loop (for how many quarters are needed), I define...
  18. Redefining a Variable but using the same name? (Beginner question)

    Hi. Is it true that when you redefine a variable using the same name, the new redefinition of the variable is not valid?

    For example, in this code, where I'm trying to output the lowest number of...
  19. Replies
    7
    Views
    1,146

    @C-Noob: I think I can use GetInt() because I...

    @C-Noob: I think I can use GetInt() because I have a pre-programmed library in my linux system.

    @Tclausex: Thank you for answering! You're absolutely right in that my second inner loop cannot...
  20. Replies
    7
    Views
    1,146

    Nested Loops is making me loopy

    So I'm taking an OpenSource C class and I literally cannot think my way through a problem. I need to get a number from a user (example: 4), and then use that number to create
    xx
    xxx
    ...
  21. Replies
    4
    Views
    858

    Got it! Thank you so much, Cat! That makes so...

    Got it! Thank you so much, Cat! That makes so much more sense. You're freaking awesome.
  22. Replies
    4
    Views
    858

    Also, I forgot to include this, but: I know you...

    Also, I forgot to include this, but: I know you can easily execute this code using the do-while loop, but I want to do it using the While loop. Thank you.
  23. Replies
    4
    Views
    858

    Beginning question about While loops

    Hello! So I'm currently trying to teach myself C via the Internet, and I'm stuck on the While loop. Here's what I'm trying to do: the user should input a non-negative number no greater than 23; if...
Results 1 to 23 of 23