Forum Replies Created

Viewing 15 posts - 46 through 60 (of 93 total)
  • Author
    Posts
  • in reply to: hi…. #3557
    GWILouisaxwzkla
    Participant

    heres a start ( I’m not certain why you are dividing every purchase in the program by 1000 ) . By the way don’t use “gotos” in high level programming languages , this is considered bad programming practice ( google Dijkstra ). Anyway , this is how I might code what you have ( the total comes out 0 since everything is divided by 1000 ). Anyway……..

    in reply to: hi…. #3555
    GWILouisaxwzkla
    Participant

    could you post your source code?

    in reply to: Need a program to capture snapshot in ‘c’ #3541
    GWILouisaxwzkla
    Participant

    Might try here :

    in reply to: Understanding Pointers and Strings #3538
    GWILouisaxwzkla
    Participant

    Heres how I might do this ( this uses pointer arthimatic instead of indexes ) :

    in reply to: Understanding Pointers and Strings #3536
    GWILouisaxwzkla
    Participant

    To understand the problem completely, remember that arrays are configured as contiguous blocks of memory ( the first index in memory precedes the next and so on ) and realize the fact that pointers are simply variables that hold the address of other variables ( the size depends on your hardware and operating system ). Also keep in mind that in C the semantic value of an array’s name is the address of the first item in the array ( array [ 0 ] ). So that in your program you have a situation like :

    since the array looks like this in memory ( let 0x0065fd94 be the first address of the array ):

    memory address item
    0x0065fd94 ‘T’
    0x0065fd95 ‘h’
    0x0065fd96 ‘i’
    0x0065fd97 ‘s’
    …………..

    and so on your loop:

    starts at index == words [ 11 ] which is ‘h’ and continues until ( *index == *(index + len); ) . But since * ( index + len ) is words [ 32 ] == ‘h’ your loop never executes. I think what you wanted to do is this:

    in reply to: Linker Errors, i do believe i need help #3524
    GWILouisaxwzkla
    Participant

    Would help to post your code and errors. Make sure that the file your including has the correct “include” syntax , like:

    and make sure that your function prototypes and declarations match perfectly or the linker will not associate the two correctly….

    in reply to: Need help URGENTLY on my assignment (instructions inside) #3523
    GWILouisaxwzkla
    Participant

    Not totally sure what you need ( not sure what the ‘p’ condition should be ) but heres a start:

    in reply to: decision program ?? #3521
    GWILouisaxwzkla
    Participant

    could do:

     

    in reply to: Some problems in C++ #3518
    GWILouisaxwzkla
    Participant

    I think read() is for arrays. Check out this link on the topic: http://www.cplusplus.com/reference/iostream/istream/read.html

    in reply to: Some problems in C++ #3516
    GWILouisaxwzkla
    Participant

    cin.get() is a member function that gets the next character from the input stream:

    in reply to: Some problems in C++ #3513
    GWILouisaxwzkla
    Participant

    This seems to work:

    in reply to: Some problems in C++ #3511
    GWILouisaxwzkla
    Participant

    for the write function I would do something like ( I don’t think I would have the console prompt inside the function , but if this is what you want ):

    in reply to: calculate and display mpg in C program #3497
    GWILouisaxwzkla
    Participant

    I think the calculation you are making here:

    is the average of the average fuel milages. I belive the calculation for average fuel milage is in fact ( miles ) / ( gallons ) and that this quantity is named “average” since calculating “actual fuel milage” would require introducing a set of standard conditions per vehicle ( standard temperature , air pressure , fuel mixture , road surface friction , weather conditions , driving style , ect. ) to arrive at the value of actual miles per gallon. Since simply dividing the number of miles driven by the number of gallons consumed ignores all the possible parameters in the problem the calculation is refered to as “average miles per gallon”. I’ll look into this but thats my guess…

    in reply to: Some problems in C++ #3506
    GWILouisaxwzkla
    Participant

    The first function “read” looks ok to output the file data one word per line ,except I would probably pass the user’s name as a parameter instead of a global variable :

    the second function for adding data to a file ( not sure why you used both fstream.h and stdio.h for file input / output in the same program ( ? ) ) seems to have some problems. First I would allocate an array of the proper size and use strcpy ( string.h ) to copy the data.

    Next , you should take read() and write() out of the conditional or the program will never end :

    thats what I see so far…..

    in reply to: Quick Sort for a Struct #3499
    GWILouisaxwzkla
    Participant

    Heres a way to do this with a doubly linked list with quicksort. This version of quicksort uses the last item in the
    list as a pivot element when partitioning.

    input:

    output ( sorting with first name as key ):

Viewing 15 posts - 46 through 60 (of 93 total)