Search:

Type: Posts; User: rstanley

Page 1 of 20 1 2 3 4

Search: Search took 0.02 seconds.

  1. Replies
    25
    Views
    1,220

    My functions were written a couple of years ago...

    My functions were written a couple of years ago to display the actual bit pattern of various data types, irregardless of signed or unsigned variables. Primarily for checking my code using bit masks,...
  2. Replies
    25
    Views
    1,220

    leo2008: Even if the value -12 is being...

    leo2008:

    Even if the value -12 is being processed as a char, the output matches the LSB (Least Significant Byte) of the full integer, -12.

    Using a function I wrote to process:

    char ch = 12;...
  3. Replies
    25
    Views
    1,220

    The following change corrects the display of the...

    The following change corrects the display of the '1', but you still have issues:
    #include <stdio.h>
    #include <stdlib.h>
    #include <stdbool.h>

    void reverse(char output[], int len)
    {
    int...
  4. Replies
    9
    Views
    573

    That is the way Dennis Ritchie created the...

    That is the way Dennis Ritchie created the function. It cleans out the input buffer, for the next line to be input. Yes, you will need to deal with removing the newline if needed. No, there is any...
  5. Replies
    7
    Views
    372

    It will at least on some compilers especially...

    It will at least on some compilers especially when you turn up the warning level on the compiler. And you should compile with high warning levels!
  6. Replies
    7
    Views
    372

    printf("\nAddress of i = %p", (void *) &i); %p...

    printf("\nAddress of i = %p", (void *) &i);
    %p should be used and the address must be cast to a void *
  7. Replies
    25
    Views
    1,220

    Show us your compile command. The code compiles...

    Show us your compile command. The code compiles on the command line and executes fine for me.
  8. Replies
    9
    Views
    573

    Vercingetorix: Short of taking a course in C...

    Vercingetorix:

    Short of taking a course in C Programming from a qualified instructor, you need to study a good book on the C Programming Language, cover to cover, and do all the exercises at the...
  9. Replies
    9
    Views
    573

    gets() reads in a line, replacing the newline...

    gets() reads in a line, replacing the newline with the terminating Nul byte, and places it in the char array passed, without ANY error checking if the array is large enough to hold it! gets() will...
  10. Replies
    25
    Views
    1,220

    This is what Salem is saying! Compare my...

    This is what Salem is saying!

    Compare my changes to your previous code:

    #include <stdio.h>
    #include <stdbool.h>

    void reverse(char output[], int len)
    {
    int start, end;
  11. Replies
    25
    Views
    1,220

    #include #include //...

    #include <stdio.h>
    #include <stdbool.h>

    // NOT

    #include <stdio.h>
    #define true 1
    #define false 0
    true and false are already defined in stdbool.h!!!
  12. Replies
    9
    Views
    573

    First of all, you should NEVER use gets()! Use...

    First of all, you should NEVER use gets()! Use fgets() instead!

    gets() was depreciated in the C99 Standard, and removed completely form the C11 Standard. If you are using an older compiler that...
  13. Replies
    25
    Views
    1,220

    leo2008: You also #include stdbool.h, but then...

    leo2008:

    You also #include stdbool.h, but then redefine "true" and "false" which are already defined in stdbool.h!

    Compile with all warnings turned on and see the results!

    Have you...
  14. For creating a library, encapsulation can be...

    For creating a library, encapsulation can be simulated with header files that are part of the library source, but not part of the API. Users of the compiled library can't see or make use of any...
  15. Replies
    15
    Views
    747

    The examples of a simple single linked list I...

    The examples of a simple single linked list I have dealt with in the past have only used Head. I have always associated Head and Tail with a double linked list. That's why I said it.
  16. Replies
    15
    Views
    747

    Although I didn't specify it, an insertNode()...

    Although I didn't specify it, an insertNode() function, implies the need for a searchNode() function with one or two node pointers to search for where in the list to insert the new node. Your term,...
  17. Replies
    15
    Views
    747

    First of all, I think you need to look for a book...

    First of all, I think you need to look for a book on algorithms and data structures, or a good online tutorial on how to create and use linked lists. Please stay away from Geekforgeeks, as I have...
  18. Replies
    15
    Views
    747

    A "List" will minimally be a pointer to the first...

    A "List" will minimally be a pointer to the first of one or more "Nodes" that contain data. "Next" in each Node will point to the next node in the list, and the last node "Next" pointer will be set...
  19. Replies
    15
    Views
    747

    They are different. The first is a NULL...

    They are different.

    The first is a NULL pointer to a LinkedList struct object that would be created later on the heap using malloc() or calloc().

    The second is an actual LinkedList object that...
  20. For starters change the first line to: ...

    For starters change the first line to:

    #include <stdio.h>
    #include <math.h>

    int main(void){
    ...
    then link in the math library. For gcc add "-lm" to link in the math library.
  21. Replies
    9
    Views
    647

    I completely disagree! If you truly understood...

    I completely disagree!

    If you truly understood pointers, you would know HOW, WHY, and WHEN to pass single pointers, and/or double pointers to a function, and return a pointer for ANY data type!!!...
  22. Replies
    9
    Views
    647

    There are several issues with your concepts of...

    There are several issues with your concepts of the definitions of "list", "node", and "single linked list" as opposed to a "double linked list", or a "circular linked list", so I will not comment any...
  23. Replies
    9
    Views
    647

    head_ref is the address of a linked list pointer...

    head_ref is the address of a linked list pointer that has been defined in the parent function, where new_node will be appended to the list.

    Yes, this can be written much better.

    Rahul11, IMHO,...
  24. You are allocating the memory for the struct...

    You are allocating the memory for the struct three times, and throwing away the memory each time returning from foo()! Allocate the memory BEFORE calling foo(), and pass in the ONE instance of the...
  25. The following is one way to write your code: ...

    The following is one way to write your code:

    #include<stdio.h>
    #include<stdlib.h>

    int main ()
    {
    int *x = malloc(5 * sizeof(*x)); // 5 * sizeof(int) NOT sizeof(int *)

    // NEVER change...
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4