Search:

Type: Posts; User: Salem

Page 1 of 20 1 2 3 4

Search: Search took 0.12 seconds.

  1. > Modify the delete_from_list function so that is...

    > Modify the delete_from_list function so that is uses only one pointer variable instead of two (cur and prev).
    I'm always suspicious of books / tutors that try to teach magic tricks as opposed to...
  2. If your list is 1 -> 2 -> 3 -> 4 -> 5 and you...

    If your list is
    1 -> 2 -> 3 -> 4 -> 5
    and you try to delete 3 by doing this
    *list = item->next;

    You end up with 4 -> 5 as your list.

    Typically, you need to keep track of the previous node as...
  3. > while (isspace(ch = getchar())) > ; > ...

    > while (isspace(ch = getchar()))
    > ;
    > while (ch != '\n' && ch != EOF) {
    The problem is that isspace('\n') is true, so you're not getting out of the first loop by typing a blank line....
  4. > void main() ... > fflush(stdin); ... > ...

    > void main()
    ...
    > fflush(stdin);
    ...
    > gets(keystr);
    My first thought would be to find someone not stuck with a 1980's DOS mentality to copy/steal code from.

    > I know that it is a...
  5. Replies
    2
    Views
    154

    Did you research the topic before you started...

    Did you research the topic before you started coding?
    Maze solving algorithm - Wikipedia
  6. Replies
    4
    Views
    154

    Try something like if ( ItemChosen == 'O' )...

    Try something like


    if ( ItemChosen == 'O' ) {
    if ( Orange <= budget ) {
    }
    }
  7. Replies
    4
    Views
    154

    Post your code.

    Post your code.
  8. Replies
    5
    Views
    151

    How To Ask Questions The Smart Way...

    How To Ask Questions The Smart Way
    How To Ask Questions The Smart Way
    Make an effort!
    Show us what you're able to manage yourself, then ask a question about the code you have.

    Don't just roll...
  9. Some fun for a lazy Saturday :) ...

    Some fun for a lazy Saturday :)


    #include<stdio.h>

    #define ASIZE 5

    void zigzag(int a[ASIZE][ASIZE]) {
    int flip = 0;
    for( int r = 0 ; r < ASIZE ; r++ ) {
  10. > Thanks. fixed those but there still is the...

    > Thanks. fixed those but there still is the segfault.
    At some point, you have to recognise that the current list is empty (head == NULL), and just return the freshly created node as being the sole...
  11. You need to make sure your new_node->next is...

    You need to make sure your new_node->next is NULL.

    > SinglyLinkedListNode *new_node = (SinglyLinkedListNode*)malloc(sizeof(SinglyLinkedListNode));
    If this really is C++, then you should be using...
  12. Do you want to make a copy of the data? int...

    Do you want to make a copy of the data?


    int from[3][3];
    int to[9];
    // some code to copy from -> to


    Or you do want to modify the array in place, then pretend it's a 1D array by pointing to...
  13. So you want to flatten 1 2 3 4 5 6 7 8 9 ...

    So you want to flatten
    1 2 3
    4 5 6
    7 8 9

    into
    1 2 3 6 5 4 7 8 9
    ?
  14. Replies
    2
    Views
    158

    If it frees all the memory you allocated during a...

    If it frees all the memory you allocated during a normal exit, that should be fine.

    Freeing all the memory in various exception cases is rather more involved.
  15. Which compiler are you using?

    Which compiler are you using?
  16. Replies
    4
    Views
    146

    Try compiling with some warnings. $ gcc...

    Try compiling with some warnings.


    $ gcc -Wall main.c
    main.c:2:6: warning: return type of ‘main’ is not ‘int’ [-Wmain]
    void main()
    ^
    main.c: In function ‘main’:
    main.c:6:16: warning:...
  17. Replies
    1
    Views
    145

    > display(choice); C doesn't do pass by...

    > display(choice);
    C doesn't do pass by reference.

    > void display(int choice)
    You have a return choice at the end.
    This won't even compile without a warning.



    int display(void){
  18. Replies
    6
    Views
    475

    Well I found BenSmith's alter ego posts: buffer...

    Well I found BenSmith's alter ego posts:
    buffer overflow
    Vulnerability in c functions
    The pastebin.com link to actual source code has long since expired.
    On the off-chance that the image...
  19. > Linux kernel wants to using Rust. References!

    > Linux kernel wants to using Rust.
    References!
  20. Replies
    10
    Views
    370

    Can you declare an array? Can you print a...

    Can you declare an array?

    Can you print a prompt?

    Can you input an integer?

    In short, show us how far you can get by yourself.
  21. Are you back again? Is Rust-Lang a replacement...

    Are you back again?
    Is Rust-Lang a replacement for C or C++?
  22. Replies
    1
    Views
    166

    You start with some research. Shortest path...

    You start with some research.
    Shortest path problem - Wikipedia

    Then you decide on a data structure to represent " The adjacency list for the graph."
  23. Replies
    3
    Views
    175

    for(i=2 ; i

    for(i=2 ; i <= low /2 ; ++i ){
    if(low % i==0) //!! what happened to these braces?
    isPrime=0;
    break;
    }
  24. Making strings constant was something added way...

    Making strings constant was something added way back in C90.
    Back then, there was still a lot of code which didn't use const properly, so you didn't get a warning.

    So as a special case, you don't...
  25. Replies
    5
    Views
    220

    You need to return the new value of the counter.

    You need to return the new value of the counter.
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4