Search:

Type: Posts; User: ginom71

Search: Search took 0.01 seconds.

  1. Replies
    13
    Views
    13,855

    Laserlight, thanks for you help. I removed the...

    Laserlight, thanks for you help. I removed the line:

    sum = SUMARRAY(x, 4, i, total);
    and replaced it with;

    SUMARRAY(x, 4, i, total);

    That cleared everything up, is that because I already...
  2. Replies
    13
    Views
    13,855

    OK, thanks everyone for the help. So you're...

    OK, thanks everyone for the help. So you're saying that I need to write it out like I would for a function, which I did (just for practice). See below:


    #include <stdio.h>
    #include <stdlib.h>...
  3. Replies
    13
    Views
    13,855

    OK, so that while loop won't compile in the main...

    OK, so that while loop won't compile in the main body of the code. I wouldn't normally use that code to sum the elements in an array anyway. I'm just pretty lost when it comes to defining this in a...
  4. Replies
    13
    Views
    13,855

    Thanks again. I read that people have had trouble...

    Thanks again. I read that people have had trouble with recursive functions in macros. I'm not sure what the benefit is except for maybe simple computations.

    So I took your suggestion, and I wrote...
  5. Replies
    13
    Views
    13,855

    What is the syntax? Do you write it like you...

    What is the syntax? Do you write it like you would normally for a function prototype? This is what I have:


    #include <stdio.h>
    #include <stdlib.h>
    #define SUMARRAY(x, y) \
    (while(y!<0){\...
  6. Replies
    13
    Views
    13,855

    loops and macros

    Hi all,

    Is it possible to include a for or a while loop in a macro? I have an assignment that says to create a macro that will sum the elements of an array, but the book, obviously, didn't show...
  7. Replies
    6
    Views
    2,789

    Thanks for the help! I was trying to experiment...

    Thanks for the help! I was trying to experiment to see if I could read the input and automatically copy the string. So I have it working, but the buffer still has some characters(not sure how). See...
  8. Replies
    6
    Views
    2,789

    Thanks for the response. I used your suggestion...

    Thanks for the response. I used your suggestion of fgets, and unfortunately it's not working. Also, shouldn't there be parentheses after "sizeof"? Thanks again for the help.


    while(fgets(choice,...
  9. Replies
    6
    Views
    2,789

    Switch statement and string copy

    Hi all,

    I'm having trouble with a function that is supposed to update records. I have copied it below:


    void updaterecord(FILE *fptr)
    {
    int record;
    int choice;
    char newname[30];
  10. Replies
    13
    Views
    2,301

    Sorry, I forgot the code to write the new data...

    Sorry, I forgot the code to write the new data into the file. It works now.
  11. Replies
    13
    Views
    2,301

    I have also tried the following: void...

    I have also tried the following:


    void eatnewline(void) {
    int x;

    do {
    x = getchar();
    } while(x != '\n' && x != EOF);
    }
  12. Replies
    13
    Views
    2,301

    Thanks again for the help. OK, I've changed your...

    Thanks again for the help. OK, I've changed your code around a little to fit my program. This is the new function prototype to insert a new record. See below:


    void newrecord(FILE *fptr)
    {...
  13. Replies
    13
    Views
    2,301

    Thanks for that. Why do you set name[index] to...

    Thanks for that. Why do you set name[index] to zero?
  14. Replies
    13
    Views
    2,301

    I am, but the problem is with input like "Sledge...

    I am, but the problem is with input like "Sledge Hammer" and then 7.50 for cost. I need to figure out how to enter strings that have spaces, and then input value for other variables.
  15. Replies
    13
    Views
    2,301

    Here's a sample of code: void newrecord(FILE...

    Here's a sample of code:

    void newrecord(FILE *fptr)
    {
    struct inventory tool = {0, "", 0, 0.0};

    int recordnum;

    printf("Enter new record (1-100): ");
    scanf("%d", &recordnum);
  16. Replies
    13
    Views
    2,301

    Strings and white space

    Is it possible to scan strings with spaces, and then other unlike int variables. For instance, if I wanted to input the name of a tool, then it's price, how would I differentiate between the two in...
  17. Thread: Creating files

    by ginom71
    Replies
    7
    Views
    1,385

    God, I can't believe a typo was causing me so...

    God, I can't believe a typo was causing me so much grief! Thanks for spotting that! It's working now. Thanks again for your help.
  18. Thread: Creating files

    by ginom71
    Replies
    7
    Views
    1,385

    OK, I used the following line to close it in the...

    OK, I used the following line to close it in the function.


    fclose(cfptr);

    When I ran the program, I still got the message "File could not be found".

    I do try to reopen it within the main...
  19. Thread: Creating files

    by ginom71
    Replies
    7
    Views
    1,385

    Creating files

    Hi all,

    I've just learned how to create files in C, and I have an entire program written for an inventory. The code compiles and runs, the problem is that the file that I have created won't open...
  20. Replies
    11
    Views
    2,303

    hehe. Syntax error on my part, must have had a...

    hehe. Syntax error on my part, must have had a brainfart. Thanks for pointing that out!
  21. Replies
    11
    Views
    2,303

    I tried this, but it didn't work. The program...

    I tried this, but it didn't work. The program just ignored my loop and continued executing.

    do{

    printf("Enter any Fahrenheit temperature above 0 and below 212 degrees: ");
    scanf("%f",...
  22. Replies
    11
    Views
    2,303

    yes. When the user is prompted to input a degree...

    yes. When the user is prompted to input a degree between 0 and 212, lets say they enter "-17". The next line that prints is "Please enter a number above 0", then the user is prompted again to enter a...
  23. Replies
    11
    Views
    2,303

    Need the best solution

    Hi all,

    I wrote a program that converts Fahrenheit temperatures to Celsius temps. I would like to have the program account for incorrect input (like a degree higher than 212 or less than 0). This...
Results 1 to 23 of 23