Search:

Type: Posts; User: Jamdog

Page 1 of 2 1 2

Search: Search took 0.01 seconds.

  1. Thread: cpp issues

    by Jamdog
    Replies
    9
    Views
    1,728

    First error says: In il.h, you need to define...

    First error says:

    In il.h, you need to define IL at a variable type, so add the red bit below:

    typedef struct ILRec
    {
    char myRowStr[30];
    int myRowInt;
    float myRowf;
    char...
  2. Replies
    2
    Views
    763

    pTot is an integer value, but you are outputting...

    pTot is an integer value, but you are outputting &pTot, which is the memory address of pTot (where the value of pTot is stored in physical memory) - just remove the &
  3. This loop: for(i=numGend-1; i >= numGend;...

    This loop:
    for(i=numGend-1; i >= numGend; i--){will never run...
    read it as:

    i = numGend-1;
    while (i >= numGend) {
    i--;
    }
    The while case is never TRUE, so the loop never executes.
  4. Replies
    23
    Views
    2,473

    Remove the semi-colon from the for loop (shown in...

    Remove the semi-colon from the for loop (shown in red below). It's preventing the 2nd line below from being looped.

    for (i = 0; i < MAX_RATERS; i++);
    sum = sum + ratings[i];...
  5. What have you done so far? Why isn't it working?...

    What have you done so far? Why isn't it working?
    Can you put your source code here (in
    ... tags)?
  6. Replies
    21
    Views
    9,325

    At a quick glance, I can't see what's wrong with...

    At a quick glance, I can't see what's wrong with it.
    Why isn't it working? What incorrect outputs are you getting? What should the correct outputs be?
  7. Replies
    21
    Views
    9,325

    Please use the tags around your source, it...

    Please use the
    tags around your source, it makes it easier for everyone to read.


    #include<stdio.h>
    #include<conio.h>
    #include<math.h>
    #define MAX 50
    #define eps 1e-6
    void...
  8. Thread: I/O

    by Jamdog
    Replies
    4
    Views
    1,500

    It could be that your file isn't the same size as...

    It could be that your file isn't the same size as your array...

    Try
    int done;
    done = fread(fp, sizeof(array),1,input);
    The done variable should equal 1 after the fread if successful, because...
  9. Replies
    6
    Views
    1,915

    Actually, while I'm thinking about it, you are...

    Actually, while I'm thinking about it, you are using 'else', so can skip the 'less-than' checks because it's implied by the 'else':

    if (age >= 65)
    {
    printf("You are an old...
  10. Replies
    6
    Views
    1,915

    Also, those else statements don't handle the ages...

    Also, those else statements don't handle the ages 65, 18 or 13. You need 'greater or equal' in a few places:


    if(age>=65)
    {
    printf("You are an old person");
    ...
  11. Replies
    5
    Views
    4,323

    Simply put, there are only really two thing to...

    Simply put, there are only really two thing to remember when working with pointers

    & is 'the address of', the physical location in memory where something is stored.
    * is 'the contents of', the...
  12. Replies
    12
    Views
    3,759

    I'm guessing we are talking about function...

    I'm guessing we are talking about function prototypes here, which there is nothing wrong with. Every book I've ever read describes prototypes as necessary. It seems odd that you think they should...
  13. Replies
    4
    Views
    5,572

    It's probably better to compare it with a 'mask'...

    It's probably better to compare it with a 'mask' that just has the one bit set. You could use:


    #define MSB_UCHAR ((unsigned char)(128)) /**< Sets to u_char MSB */

    int getSign(unsigned...
  14. Replies
    16
    Views
    5,880

    You are quite correct ;)

    You are quite correct ;)
  15. The easiest way to sort date is to output it like...

    The easiest way to sort date is to output it like YYYY-MM-DD and then perform an alphabetic sort.
  16. Replies
    14
    Views
    2,404

    A float is only accurate to a few decimal places,...

    A float is only accurate to a few decimal places, but you can use:

    printf("The sum is %.2f", sum);to force it to show to 2 decimal places.
  17. Replies
    8
    Views
    2,762

    Just parse the array, checking each element...

    Just parse the array, checking each element against the one before it.
    Assuming you have your sorted array (of integers?) called myArray, and it has array_size elements:


    int i;
    /* Note, start...
  18. Replies
    23
    Views
    4,817

    What is this line doing? my_employee =...

    What is this line doing?


    my_employee = malloc(200);

    As far as I can see, it would cause you to lose the contents of my_employee every time add_employee is called.
  19. Replies
    16
    Views
    5,880

    I'd probably create a 2nd array, sort the 1st...

    I'd probably create a 2nd array, sort the 1st array into the 2nd (to make a sorted array). You can then easily find the 'kth' largest and smallest with sorted_array[(k-1)] and...
  20. Replies
    8
    Views
    2,762

    If a postive integer string can only contain the...

    If a postive integer string can only contain the characters 0 to 9, it's easy enough to create a function to check it:


    bool is_positive_number(const char *str)
    {
    int i;

    /* Validate that...
  21. Replies
    5
    Views
    6,588

    Thanks bithub, I've passed the link on to my...

    Thanks bithub, I've passed the link on to my brother.

    I'm still interested in creating a simple bespoke version for him, and have thrown together some basic functions. Please note that this is...
  22. Replies
    5
    Views
    996

    This is difficult to follow, and the reason I use...

    This is difficult to follow, and the reason I use #defines for bitvector work. Get the defines right, and it's easier to work with:


    #define ST_NUM(x) ((x) & STUDENT_ID_MASK)
    #define...
  23. Replies
    8
    Views
    4,125

    You should have a default case in your switch: ...

    You should have a default case in your switch:


    case 6997 : strcpy(coursePrefix, "GOL 127"); creditHours = 1; break;
    default : strcpy(coursePrefix, "Invalid"); creditHours = 0; break;
    ...
  24. Replies
    7
    Views
    1,274

    I'd also suspect the batch file. Look for a...

    I'd also suspect the batch file. Look for a PAUSE or CHOICE line in there, which are commonly used to wait for a keypress.
  25. Replies
    5
    Views
    3,264

    After the while loop, you need to NULL terminate...

    After the while loop, you need to NULL terminate the char * string, like

    str[i] = '\x0';
Results 1 to 25 of 30
Page 1 of 2 1 2