Search:

Type: Posts; User: Salem

Page 1 of 20 1 2 3 4

Search: Search took 0.18 seconds.

  1. Replies
    2
    Views
    124

    > int **arr = calloc(N, sizeof(int *)); > ...

    > int **arr = calloc(N, sizeof(int *));
    > arr = calloc(N, sizeof(int));
    You have two things called 'arr' going on at the same time.

    > max = arr[j];
    > arr[j] =...
  2. The way you handle the return results of all your...

    The way you handle the return results of all your send/recv calls are wrong.

    Neither guarantee complete success or complete failure. You have to deal with partial success as well.

    n =...
  3. Replies
    2
    Views
    105

    > scanf("%s%*c", &yesNo); The %s conversion...

    > scanf("%s%*c", &yesNo);
    The %s conversion needs at least TWO characters of storage
    - the char you type
    - the \0 character.

    Perhaps with a leading space to %c, you can get what you want....
  4. Replies
    1
    Views
    80

    to convert two-dimensional array to...

    to convert two-dimensional array to one-dimensional

    No thoughts at all as to how to go about this?
    Just dumping your assignment isn't going to make us write all the code for you.
  5. Is your ISR attached to your button or your PWM...

    Is your ISR attached to your button or your PWM pin?

    I'm guessing you have something like this to test on (for example).
    AVR Development Kit - Tutorials

    It would be really useful if you posted...
  6. So is it like this? - press (and release)...

    So is it like this?

    - press (and release) button, PWM pattern 1 starts.
    - press (and release) button, PWM pattern 1 stops.
    - press (and release) button, PWM pattern 2 starts.
    - press (and...
  7. Thread: Beginner help

    by Salem
    Replies
    3
    Views
    99

    1. Make all your functions return a proper type....

    1. Make all your functions return a proper type.
    2. There's no benefit to writing code all on one line.
    3. There's no benefit in abusing the comma operator.
    4. There's no need for a trailing ; at...
  8. > 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...
  9. 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...
  10. > 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....
  11. > 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...
  12. Replies
    2
    Views
    168

    Did you research the topic before you started...

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

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

    Try something like


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

    Post your code.

    Post your code.
  15. Replies
    5
    Views
    158

    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...
  16. 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++ ) {
  17. > 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...
  18. 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...
  19. 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...
  20. 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
    ?
  21. Replies
    2
    Views
    165

    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.
  22. Which compiler are you using?

    Which compiler are you using?
  23. Replies
    4
    Views
    151

    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:...
  24. Replies
    1
    Views
    152

    > 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){
  25. Replies
    6
    Views
    491

    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...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4