User Profile

Collapse

Profile Sidebar

Collapse
UofFprogrammer
UofFprogrammer
Last Activity: Dec 9 '07, 06:11 PM
Joined: Sep 9 '07
Location: Gainesville
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • UofFprogrammer
    replied to Help* Please
    in C
    You did an excellent job copying from the book Absolute C++ By Savitch. I remember reading that exact code a while ago.
    To quote the Moderators:
    But to get you on the right track, the new classes that you need to write will all inherit some of the base classes you just copied. For example: temporary, administrative, and permanent employees are all Savitch employees. You can use that as a base class. In your new classes you can further...
    See more | Go to post

    Leave a comment:


  • UofFprogrammer
    replied to Overloading the =Operator
    in C
    Weaknessforcats , you hit the nail on the head. That was the situation that was in the book with dynamically allocated assets being deleted before being reassigned. I was curious if there was ever a situation where that code would be done intentionally or if it was just programmer error.

    Thanks for the response!...
    See more | Go to post

    Leave a comment:


  • UofFprogrammer
    replied to Overloading the =Operator
    in C
    I understand the safety code part, but I couldn't think of an intentional situation where the code would have same object on both sides of the assignment operator.
    See more | Go to post

    Leave a comment:


  • UofFprogrammer
    started a topic Overloading the =Operator
    in C

    Overloading the =Operator

    Hello,
    I was taking a look at overloading the = operator in a C Plus Plus book. Part of the code of the overloaded =operator included checking for the case when the same object was on both sides of the equal sign. When and why would you have a situation like this?
    Code:
    someobject1=someobject1;
    Thank You
    See more | Go to post

  • Thanks,
    I figured out what was causing the problem. The
    Code:
    while(getline(file,line)){
    wasn't the problem. What was causing the program to crash was inside the while loop. I didn't realize that getline will actually return a string with nothing in it for an empty line. As I was parsing the data, if there was a white space, the string length was (previously not so obvious to me) 0. I had a couple of functions that assumed that the string length...
    See more | Go to post

    Leave a comment:


  • Inputting From an External File and Testing for End of File

    Hello,
    Several Weeks ago I asked a question about testing for the end of an input file.
    I have been using this method pretty well for inputting information from an external file. I am using C++.
    Code:
    char line[50];
    while(file>>line){
    Where line is a c-string and file is an input stream. But this only reads until the first space it encounters. I now want to try to take in an entire line, regardless of what...
    See more | Go to post

  • UofFprogrammer
    started a topic Constructor Statements
    in C

    Constructor Statements

    Hello,
    I was (once again) experimenting with some CPP code using constructors. I defined a constuctors 2 different ways. I believe the end result is the same, but what causes the difference in run-time for the program. Specifically, the first code took my computer 9 seconds to run, while the second code took 15 seconds, a 66% difference. I repeated the "experiment " several times and got the same result. I'm guessing that the first...
    See more | Go to post
    Last edited by UofFprogrammer; Oct 26 '07, 02:09 AM. Reason: Typo

  • UofFprogrammer
    replied to Testing for End of File in I/O
    in C
    Thanks for the very detailed response; it was very informative! I was considering using the getline function, but I wasn’t sure how I could parse the data inside of the string. Would it be correct to assume if I were to take in the entire line, and it happened to be an empty string, I could test for it and then end the loop?
    Would you consider this code to be more robust?
    Code:
    #include<iostream>
    #include<fstream>
    ...
    See more | Go to post

    Leave a comment:


  • UofFprogrammer
    started a topic Testing for End of File in I/O
    in C

    Testing for End of File in I/O

    I am experimenting with several ways to test for the end of file for an input file .txt
    If, for example, I have a text (test.txt) file that had:

    ab 5
    fgd 3
    fdfe 3
    aasa 4
    (intentionally blank line)
    where the first input is a character array and the second is an integer value.

    I could write
    Code:
    #include<iostream>
    #include<fstream>
    using namespace
    ...
    See more | Go to post

  • UofFprogrammer
    replied to Program to Test Large Number for Prime
    in C
    Could you perhaps provide a (simple) example to help me get started?

    Thank you...
    See more | Go to post

    Leave a comment:


  • UofFprogrammer
    replied to Program to Test Large Number for Prime
    in C
    Thanks, but is there a way I can put very large numbers in? I can put a lage (50+ digit) number into an array, but I'm not sure how i could handle division in this case.
    I am particularly interested in the RSA- Factoring Challenge where the numbers can be as long as 600+ digits.

    http://en.wikipedia.org/wiki/RSA_Factoring_Challenge
    Any advice?

    I tried the unsigned long long int and that worked, but I wanted...
    See more | Go to post

    Leave a comment:


  • UofFprogrammer
    started a topic Program to Test Large Number for Prime
    in C

    Program to Test Large Number for Prime

    For a fun challenge, I am trying to create a C++ program that will determine if a number is prime. I am getting to problems when I reach a large values (over 9 or so digits).
    How can I increase the number of digits i can use?
    For example, when i use the number 4362206209 (which I know for a fact is prime) it returns 2 as a factor, which it isn't.
    Eventually, I would like to get to long (50+ digit) numbers. I know this calculation...
    See more | Go to post
    Last edited by Ganon11; Oct 1 '07, 10:55 PM. Reason: Please use the [CODE] tags provided.

  • Thanks a bunch, that answered my question!
    See more | Go to post

    Leave a comment:


  • UofFprogrammer
    started a topic Quick question with char in logic statement
    in C

    Quick question with char in logic statement

    I am trying to create a program that will accept either a character or integer value and then use it in a logic statement. However, when I run this sample program, if i put 1 in for choice, it will not run the if statement. What am I missing?

    #include<iostre am>
    using namespace std;

    int main () {
    char choice;
    cout<<"choice: ";
    cin>>choice;
    ...
    See more | Go to post
No activity results to display
Show More
Working...