User Profile

Collapse

Profile Sidebar

Collapse
toefraz
toefraz
Last Activity: Sep 24 '08, 12:53 AM
Joined: Nov 12 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • toefraz
    replied to words within a word
    in C
    I looked at that algorithm, but it requires looking at each word in the dictionary, and then seeing if it can be made from the given word, and is a very slow algorithm (takes about 15seconds on my core 2 duo 2ghz!) I know the faster way would be to find all combinations of the given word and matching them against the dictionary because then you wouldn't have to check every single dictionary entry. I just can't figure out how to do the combinatorial...
    See more | Go to post

    Leave a comment:


  • toefraz
    started a topic words within a word
    in C

    words within a word

    Hi all. I've been given an assignment to construct an algorithm that can find all words that occur within a given word. For example:

    Given furthermore, solutions could be
    form,
    the,
    further,
    more,
    theme
    ...and so on.

    I thought about using the STL next_permutatio n() function, but it only finds permutation with the same amount of letters. Searching the dictionary for correct words...
    See more | Go to post

  • toefraz
    started a topic Something other than .txt's
    in C

    Something other than .txt's

    Hey, guys. I'm working on a quote generating program that displays a random quote from a text file. I was just wondering if there was anyway to put that textfile inside of the .exe or make the txt file into something non-edittable. I'm new at this so I don't know all of my options. I would just like a little nudge in the right direction.

    Any help would be appreciated. Thanks
    See more | Go to post

  • Just split the the declaration in two:

    Code:
    ifstream file_to_open;
    file_to_open.open(c_str);
    See more | Go to post

    Leave a comment:


  • You are declaring the class member functions twice, once in your class and again in your driver. Take out the declarations in your driver file and see if that helps at all.
    See more | Go to post

    Leave a comment:


  • toefraz
    started a topic Basics of creating a database in c++
    in C

    Basics of creating a database in c++

    Hey, guys. I want to learn how to start making databases. I was wondering if anyone knew a good beginners tutorial, or just know some good pointers. Thanks, in advance.
    See more | Go to post

  • toefraz
    started a topic Problem with static data members
    in C

    Problem with static data members

    Hey, guys. I have an assignment to work with static data members with numbers. I've done all the programming needed, but I keep getting this error when I try to compile:

    Code:
    1>Number.obj : error LNK2005: "private: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > * Number::tens" (?tens@Number@@0PAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)
    ...
    See more | Go to post

  • toefraz
    replied to vector sort for high scores
    in C
    Oh ok. We haven't gotten to structs yet in class. I'll research them. Thanks for you help.
    See more | Go to post

    Leave a comment:


  • toefraz
    replied to vector sort for high scores
    in C
    I sort of got it working by using
    [CODE=c]sort(v.begin(), v.end(), greater<string> ());[/CODE]
    but it is sorting the scores like this:

    Code:
    975       toefraz   Sun Jan 13 03:33:01 2008
    550       toefraz   Sun Jan 13 04:07:07 2008
    440       toefraz   Sun Jan 13 04:19:52 2008
    330       toefraz   Sun Jan 13 04:26:21 2008
    323       toefraz   Sun Jan 13 03:33:01 2008
    25        toefraz
    ...
    See more | Go to post

    Leave a comment:


  • toefraz
    replied to Wanting a simple way to generate a random number
    in C
    First off, you need to seed your random number generator. A good way to do this is with your system clock, as the number it seeds with changes everytime the program runs. To do this you need the <ctime> header and place

    [CODE=c]srand(time(0));[/CODE]

    before your rand() function in main.

    To address the issue of getting either a 0 or a 1, use the modulus operator:

    [CODE=c]rand() % 2...
    See more | Go to post

    Leave a comment:


  • toefraz
    started a topic vector sort for high scores
    in C

    vector sort for high scores

    Hi, guys. I'm writing a little game, and I want to include a high scores list.
    I've got everything coded except for the sorting part. I want to use the std::sort() function, but I'm not quite sure how I could get it to work with the data in my vector.

    Here is a sample high score file in which each line is inputted into a vector element. I want to sort by the score:

    Code:
    2345     toefraz     day time year
    1009
    ...
    See more | Go to post

  • toefraz
    started a topic asctime without trailing newline character
    in C

    asctime without trailing newline character

    Hello, all. I am writing a patch of code that displays the time and date in the middle of the line. I am using the asctime function from ctime but I don't want the trailing newline character after the execution.

    Is there any way to remove it, or should I go about finding the time using a different method?

    Code:
    ostream &td(ostream &stream)
    {
      time_t t;
      
      t = time(NULL);
      stream
    ...
    See more | Go to post

  • toefraz
    replied to Getting the first numbers from a string
    in C
    Here's my final function. Tell me if you think there is a better way to go about doing this:

    [CODE=c]void rankSearch()
    {
    string str;
    int rank = 0, count = 0, leave = 0;

    cout << "Please enter a ranking (1-1000): ";

    do
    {
    getline(cin >> ws, str);
    str += "fillfillfi ll"; //Fill up the string to prevent issues if there are less...
    See more | Go to post

    Leave a comment:


  • toefraz
    replied to Getting the first numbers from a string
    in C
    I had it where it would change str2 into a char array, then just use atoi on the the char array, but i changed it to just use a .c_str() on str1. I just didn't remove the str2. I got it working finally. I just had to fill up the string past 4 characters otherwise it would try to access out-of-bound data.
    See more | Go to post

    Leave a comment:


  • toefraz
    started a topic Getting the first numbers from a string
    in C

    Getting the first numbers from a string

    Hey, guys. I'm writing a program that searches through a census file and returns a name for a inputted rank. I've been trying to get this function to parse the rank string to only get only the digits in the first 4 places so that it would only return a string whose value ranges from 0 - 9999. Here's what I have so far, and it's not done by any means:

    Code:
    void rankSearch()
    {
    	string str1 = "", str2 = "";
    ...
    See more | Go to post

  • toefraz
    replied to Sorting names and IDs
    in C
    I'm sorting by names. I think I'll just use strcat to put the name and id into one string and just sort using a 1d algorithm then split them apart.

    Or do you think another way would be easier/more efficient?
    See more | Go to post

    Leave a comment:


  • That's cool. I didn't know such a thing existed. I'll have to read up on stringstreams.
    See more | Go to post

    Leave a comment:


  • It's pretty simple. Just use the itoa function with the cstdlib header.

    Example:

    [CODE=c]int number = 1200;
    char numArray[10]; //Size of 10 should be good, can increase if needed.
    itoa(number, numArray, 10); //10 is for the base.
    string str = numArray; //Convert to a string (requires string header)[/CODE]
    See more | Go to post

    Leave a comment:


  • toefraz
    started a topic Sorting names and IDs
    in C

    Sorting names and IDs

    Hey, guys. I've been using a selection sort for sorting 1d arrays, but now i've got a 2d array with names and ids.

    Code:
    string employee[name][id]
    and i can't figure out how to change the algorithm to sort just the names and have the ids still attached to them such as:

    Code:
    Smith, John 12
    Q, Suzie 47
    Ford, Henry 22
    yields

    Code:
    Ford, Henry 22
    Q, Suzie 47
    Smith, John 12
    any help would be much ...
    See more | Go to post
No activity results to display
Show More
Working...