Search:

Type: Posts; User: rstanley

Page 1 of 20 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    4
    Views
    92

    You need to post the actual code you typed into a...

    You need to post the actual code you typed into a file and attempted to compile, not a image of your handwritten code!

    We cannot compile and test handwritten code, or an image! Nor do you know if...
  2. Replies
    4
    Views
    92

    You need to make a first attempt yourself. Then...

    You need to make a first attempt yourself. Then if you are having problems, post the code in CODE blocks, and ask specific questions. We cannot and do not do your work for you.

    Please read the...
  3. Also, please remove the call to "fflush(stdin)"...

    Also, please remove the call to "fflush(stdin)" fflush() is for output files only. Please read why.

    Use this instead:

    int ch = 0;
    while ((ch = getchar()) != '\n' && ch != EOF);
    ch must...
  4. We all know how to declare and define functions,...

    We all know how to declare and define functions, but the acronym, "UDF", is never used by most programmers. I wonder where you learned this acronym.
  5. "User-Defined Function" maybe? Bad instructor,...

    "User-Defined Function" maybe?

    Bad instructor, book, video, or so-called tutorial I suspect.
  6. Replies
    5
    Views
    236

    "Dynamic Memory Allocation" functions such as...

    "Dynamic Memory Allocation" functions such as malloc() and calloc() allocate memory from the "Heap" for use by the program. They have nothing to do with assigning any data to the allocated memory....
  7. Replies
    7
    Views
    181

    So the output you displayed above is what you...

    So the output you displayed above is what you expect? What is the actual output from your code?

    We can't program the code for you. You have to make an attempt, and post your code so we can...
  8. Replies
    7
    Views
    181

    Programmers invented spell checker programs! ;^)...

    Programmers invented spell checker programs! ;^)

    Then why specify using the Python RNG???

    Post your code if have some problem with your code, and ask specific questions.
  9. Replies
    7
    Views
    181

    Bad at spelling also! This is a C forum. The...

    Bad at spelling also!

    This is a C forum. The instructions say to use the Python RNG, rather than the C version. Why do you think you should be coding the program in C!
  10. Thread: Struct + File

    by rstanley
    Replies
    5
    Views
    476

    rusyoldguy & Syazzz: Instead of using:...

    rusyoldguy & Syazzz:

    Instead of using:
    scanf("%[^\n]", b.plateNo);
    I strongly urge the use of fgets() instead and then remove the newline form the end of the string.

    scanf() is fine for...
  11. Replies
    2
    Views
    265

    Yes, "ARTNAME" should be a #define.

    Yes, "ARTNAME" should be a #define.
  12. Replies
    15
    Views
    579

    Yes. char *sortedwordArray = (char)...

    Yes.

    char *sortedwordArray = (char) malloc(num_words * sizeof(char));
    sortedwordArray is a char *
    malloc() returns a void *
    You are casting a void * to a char (Not a pointer) then assigning to...
  13. Replies
    15
    Views
    579

    char *ptr = NULL; ptr = malloc(64); //...

    char *ptr = NULL;
    ptr = malloc(64);
    // NOT
    ptr = (char *) malloc(64);


    malloc() returns a "void *" (Generic typeless pointer) which can be, and should be, assigned to a pointer of...
  14. Replies
    11
    Views
    459

    You have to open the file for reading before you...

    You have to open the file for reading before you can process the file!

    Where is your call to fopen()?
  15. Replies
    8
    Views
    452

    There are several options: 1) Use fgets() to...

    There are several options:

    1) Use fgets() to input the entire line, including the newline, then process the line as needed.

    2) After a getchar():

    int ch;
    while ( ( ch = getchar() ) != EOF...
  16. Replies
    8
    Views
    452

    Please initialize all your local variables. ...

    Please initialize all your local variables. Sooner or later you will get burned with garbage data in an uninitialized local variable.

    That in addition to my recommendations in my first...
  17. Replies
    8
    Views
    452

    You should a full program with the main()...

    You should a full program with the main() function so we can compile and test the program.

    fflusf() is for output files only, fflush(stdin) should NEVER be used!


    srand((unsigned) time(NULL));...
  18. Replies
    5
    Views
    381

    How are you learning C? Are you taking a...

    How are you learning C?

    Are you taking a course from a qualified instructor, studying by yourself from an up to date book on C, or online tutorials and/or YouTube videos?

    In any case, you...
  19. This is a nice bar bet, but I don't know any...

    This is a nice bar bet, but I don't know any programmer that would use this in real life.

    This can be more simplified by:

    number1 ^= number2;
    number2 ^= number1;
    number1 ^= number2;
    // Or...
  20. Replies
    3
    Views
    395

    Before you attempt to program in C, you first...

    Before you attempt to program in C, you first need to study a good book on the C Programming Language, cover to cover, and do all the exercises at the end of each chapter! Choose one of the three...
  21. Replies
    7
    Views
    509

    Understood. Please apply at least some of my...

    Understood. Please apply at least some of my suggestions above.

    You need to study a good book on the C Programming Language, cover to cover, and do all the exercises at the end of each chapter! ...
  22. Replies
    7
    Views
    509

    You should initialize all local variables to zero...

    You should initialize all local variables to zero or some meaningful values.

    You assume whole numbers, you should use floats or doubles for all prices and budgets. Are all fruit whole dollars,...
  23. Replies
    7
    Views
    509

    Since ItemChosen is a single char, you could use...

    Since ItemChosen is a single char, you could use a switch - case statement instead of the if statements.

    Also, I would break this single main() function into individual functions.
  24. Replies
    213
    Views
    10,024

    If you are interested in viewing C code, may I...

    If you are interested in viewing C code, may I suggest downloading and looking at the GNU coreutils to see some of the source code that makes up the Linux O/S?

    You can download the code here....
  25. Replies
    12
    Views
    583

    This forum is for the discussion of C not C++. ...

    This forum is for the discussion of C not C++. You should post in the C++ forum.
Results 1 to 25 of 500
Page 1 of 20 1 2 3 4