Thread: c++ string creation and file manipulation

  1. #16
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    To KingZoolerius66:
    Did it not give you any errors when compiling it? You definitely need that one line; it fixes all errors (believe me, i tried it just now).
    For your information, you could replace that one line with these ones:
    using std::ofstream;
    using std::cin;
    using std::ios;

    If you don't get what I'm talking about, you need some series review on it. Every C++ beginner know about this.

  2. #17
    Registered User
    Join Date
    Sep 2003
    Posts
    71
    ok, ok, relax, calm down man. I know about using namespace std;

    Why would I(me) get any errors? I already have that line in my source code. I'm not the beginner, you don't have to address me. Even without that line I get no errors, I'm using Dev-C++.
    Name: Eric Lesnar
    Learning: C/C++, SDL, WinAPI, OpenGL, and Python
    Compiler: Dev-C++ 4.9.0
    Current Game Project: Acoznict

  3. #18
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696
    I was just trying to help the other guy troubleshoot the errors. You should've pointed out the "using namespace" issue in addition to this comment.
    C:\Program Files\Microsoft Visual Studio\MyProjects\Generator\generator.cpp(13) : error C2065: 'ofstream' : undeclared identifier

    That error isn't my fault. ofstream is un-identified because you didn't include fstream. "ofstream" is a output file stream class in fstream.h

    Without including that file, the compiler won't know what that is.
    You might be an expert, but not the other guy, I suppose

  4. #19
    Registered User
    Join Date
    Sep 2003
    Posts
    71
    Yeah, I was thinking about it but didn't write it down/post it. Looks like he isn't online or on the boards anymore.

    Anywhoo, did my little source code fit his description in his original post?
    Name: Eric Lesnar
    Learning: C/C++, SDL, WinAPI, OpenGL, and Python
    Compiler: Dev-C++ 4.9.0
    Current Game Project: Acoznict

  5. #20
    unleashed alphaoide's Avatar
    Join Date
    Sep 2003
    Posts
    696

    Re: c++ string creation and file manipulation

    If I read the problem description...
    how would i go about creating a c++ program that generates strings that range from 1 character to 8 characters (all asci) in such a way that all possible combinations are recorded in a simple txt file?
    Assuming that a character means an alphabet, it should give the following output on the txt file.
    A
    B
    ...and so on
    AA
    AB
    ..and so on
    BA
    BB
    ...and so on
    AAAAAAAA
    ....
    DKSAJSLH
    ...
    ZZZZZZZZ
    Just ask the other guy to clarify. He probably wants to write program to break a password

  6. #21
    Registered User
    Join Date
    Sep 2003
    Posts
    71
    probably

    I have to go now. It's getting late.
    Name: Eric Lesnar
    Learning: C/C++, SDL, WinAPI, OpenGL, and Python
    Compiler: Dev-C++ 4.9.0
    Current Game Project: Acoznict

  7. #22
    Registered User
    Join Date
    Sep 2003
    Posts
    7
    ok, well, it seems to be working now, but i dont understand what its doing, i enter in a string and it just stops

    what i want it to do is create strings ranging from at least 1 char to 8 chars, using every possible combination and saving them all to a txt file, is this possible and how much hdd space would it take?

  8. #23
    Registered User
    Join Date
    Sep 2003
    Posts
    71
    Harddrive space is the least of your worries. If you want to create random strings ranging from 1 character to 6 or 8 then do this:

    Code:
    // Change the last arguement of this function call and 
    // that is how many characters your word will have.
    PrintRandomWord( PrintLetter, 6, 5 );
    Name: Eric Lesnar
    Learning: C/C++, SDL, WinAPI, OpenGL, and Python
    Compiler: Dev-C++ 4.9.0
    Current Game Project: Acoznict

  9. #24
    Registered User
    Join Date
    Sep 2003
    Posts
    7
    ive limited the scope from varrying string lengths to a static length of 6, the strings consist of numbers and letters, (lowercase only) i want it to output in the form of a txt file a 6 digit string, starting at 000000 and ending at zzzzzz , if my calculations are correct, the size of the hdd needs to be at least 17gb (8*36^6 bytes)

    8 being the number of bits per byte
    36 being the number of available variables (26 alpha chars, 10 numer chars)
    6 being the length of the string

  10. #25
    Registered User
    Join Date
    Sep 2003
    Posts
    71
    I'm going to post a portion of an AIM conversation that I just had with one of my masterful programming profesors.


    mr spyffi (3:55:15 PM): He wants all the possible combinations.
    KingZoolerius666 (3:55:29 PM): I still don't get it
    KingZoolerius666 (3:55:32 PM): why would he want that?
    mr spyffi (3:55:43 PM): To crack a password, maybe?
    KingZoolerius666 (3:55:43 PM): why not just write a program that prints out the random combos
    mr spyffi (3:55:48 PM): Or just for the sake of randomness.
    mr spyffi (3:56:27 PM): If you look at 8-character strings, assuming a 72 letter alphabet (lowercase letters + uppercase letters + 10 digits + 10 symbols), you get 722204136308736 different combinations.
    mr spyffi (3:56:57 PM): That's 6053445 gigabytes just for the 8-letter possibilities.
    KingZoolerius666 (3:57:11 PM): holy $$$$
    mr spyffi (3:57:17 PM): Even more, actually, since you're on Windows.
    mr spyffi (3:57:33 PM): (8 letters + \r at the end of a line + \n at the end of a line)
    KingZoolerius666 (3:57:33 PM): would be lower on Linux?
    mr spyffi (3:57:44 PM): Not really.
    mr spyffi (3:58:06 PM): It's still (that many) gig, and then some, on Linux or Mac, but it would be more on PC.
    mr spyffi (3:58:24 PM): That's because Linux and Mac only use one byte for \n, but Windows uses 2.



    I hope you change your mind about this...
    Name: Eric Lesnar
    Learning: C/C++, SDL, WinAPI, OpenGL, and Python
    Compiler: Dev-C++ 4.9.0
    Current Game Project: Acoznict

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  2. Constructive Feed Back (Java Program)
    By xddxogm3 in forum Tech Board
    Replies: 12
    Last Post: 10-10-2004, 03:41 AM
  3. file processing updating record error
    By uuser in forum C Programming
    Replies: 2
    Last Post: 04-27-2003, 12:13 AM
  4. File Creation with fixed PREFIX & SUFFIX !!!
    By mehuldoshi in forum C Programming
    Replies: 2
    Last Post: 07-29-2002, 06:02 AM
  5. Simple File Creation Algorithm
    By muffin in forum C Programming
    Replies: 13
    Last Post: 08-24-2001, 03:28 PM