Results 1 to 6 of 6
  1. #1
    m4c4r0ni3z's Avatar
    Join Date
    Aug 2007
    Gender
    male
    Location
    I'm in your memory, caving your codes.
    Posts
    161
    Reputation
    13
    Thanks
    38
    My Mood
    Breezy

    [Release] Simple Program

    All it does is compare string size/length. The book I'm reading (C++ Primer) wanted me to make it, so here you are. Source is included lol

    Virustotal. MD5: 48a4661deac3c927584c21df220341b9
    Sigs are for pussies


    MOTHA FUCKA STAY BREEZY

  2. #2
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    Well your program works perfect, but your form is a little off:
    Instead of this:
    Code:
    using std::string;
    using std::cout;
    using std::cin;
    using std::endl;
    Most ppl would just use
    Code:
    using namespace std;
    But I don't know how your book teaches you so I won't press my point.

    Also it is "bad practice" to right if statements like this:
    Code:
    if (input1 == input2)
    		cout << "The strings are the same size. \n\n" << endl;
    	if (input1 > input2)
    		cout << "String 1 is bigger. \n\n" << endl;
    	if (input1 < input2)
    		cout << "String 2 is bigger. \n\n" << endl;
    It would be better to write it like this:
    Code:
    if (input1 == input2)
    		cout << "The strings are the same size. \n\n" << endl;
    	else if (input1 > input2)
    		cout << "String 1 is bigger. \n\n" << endl;
    	else if (input1 < input2)
    		cout << "String 2 is bigger. \n\n" << endl;
    Again if you havent learned about else if statements I won't pressure you ur book will cover it in due time, but there are a couple of good reasons to use else if statements:

    It Creates faster code at run time. When you use else if statements and an evaluation proves true for 1 if the subsequent else if statements would not be executed. In your code unnecessary evaluations would still be carried on after a preceding if statement proves true. While speed may not be a big concern for a small program like yours, these little slow-downs add up in larger programs and can cause noticeable differences at runtime. The best way to keep this from happening later on is to practice it now when your just learning it. Because its hard to remember the little details like this when ur working on a large project if you don't already know them inside and out.

    Ok well good code and everything btw if you want to see something cool try this. Choose option 1. Type 20 a's for the first string and 1 "z" for the second string. String 2 will be longer because when you compare the size of strings it compares their values lexicographically (that's alphabetically) Just so you know its the alphabetical order and NOT the physical size (in memory) of the string.

    Here's my edited version of your program: Hope u don't mind ;P
    Last edited by why06; 08-13-2009 at 09:37 PM.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  3. #3
    m4c4r0ni3z's Avatar
    Join Date
    Aug 2007
    Gender
    male
    Location
    I'm in your memory, caving your codes.
    Posts
    161
    Reputation
    13
    Thanks
    38
    My Mood
    Breezy
    Quote Originally Posted by why06 View Post
    Well your program works perfect, but your form is a little off:
    Instead of this:
    Code:
    using std::string;
    using std::cout;
    using std::cin;
    using std::endl;
    Most ppl would just use
    Code:
    using namespace std;
    But I don't know how your book teaches you so I won't press my point.

    Also it is "bad practice" to right if statements like this:
    Code:
    if (input1 == input2)
    		cout << "The strings are the same size. \n\n" << endl;
    	if (input1 > input2)
    		cout << "String 1 is bigger. \n\n" << endl;
    	if (input1 < input2)
    		cout << "String 2 is bigger. \n\n" << endl;
    It would be better to write it like this:
    Code:
    if (input1 == input2)
    		cout << "The strings are the same size. \n\n" << endl;
    	else if (input1 > input2)
    		cout << "String 1 is bigger. \n\n" << endl;
    	else if (input1 < input2)
    		cout << "String 2 is bigger. \n\n" << endl;
    Again if you havent learned about else if statements I won't pressure you ur book will cover it in due time, but there are a couple of good reasons to use else if statements:

    It Creates faster code at run time. When you use else if statements and an evaluation proves true for 1 if the subsequent else if statements would not be executed. In your code unnecessary evaluations would still be carried on after a preceding if statement proves true. While speed may not be a big concern for a small program like yours, these little slow-downs add up in larger programs and can cause noticeable differences at runtime. The best way to keep this from happening later on is to practice it now when your just learning it. Because its hard to remember the little details like this when ur working on a large project if you don't already know them inside and out.

    Ok well good code and everything btw if you want to see something cool try this. Choose option 1. Type 20 a's for the first string and 1 "z" for the second string. String 2 will be longer because when you compare the size of strings it compares their values lexicographically (that's alphabetically) Just so you know its the alphabetical order and NOT the physical size (in memory) of the string.

    Here's my edited version of your program: Hope u don't mind ;P
    Yea i've still got a ways to go so it hasnt taught me things like else if, namespace std, etc. It's all in due time tho
    Sigs are for pussies


    MOTHA FUCKA STAY BREEZY

  4. #4
    !~_Creedy_~!'s Avatar
    Join Date
    Jun 2009
    Gender
    male
    Location
    Photoshop CS4
    Posts
    798
    Reputation
    15
    Thanks
    156
    My Mood
    Cool
    Cool simple program... keep practicing maybe one day you make hacks!!

  5. #5
    m4c4r0ni3z's Avatar
    Join Date
    Aug 2007
    Gender
    male
    Location
    I'm in your memory, caving your codes.
    Posts
    161
    Reputation
    13
    Thanks
    38
    My Mood
    Breezy
    Lol i can make hacks, the problem is i can ONLY make hacks >.>
    Sigs are for pussies


    MOTHA FUCKA STAY BREEZY

  6. #6
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    Quote Originally Posted by m4c4r0ni3z View Post
    Lol i can make hacks, the problem is i can ONLY make hacks >.>
    Agreed. Making game hacks is a lowly existence as a programmer, no matter how good u r.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

Similar Threads

  1. [Release] My first simple program
    By thomy07 in forum Visual Basic Programming
    Replies: 16
    Last Post: 07-13-2010, 03:34 AM
  2. [RELEASE] Tap Program
    By gbitz in forum Combat Arms Hacks & Cheats
    Replies: 22
    Last Post: 08-04-2008, 01:38 PM
  3. (Release) Simple Scopey [c++]
    By niek123 in forum WarRock - International Hacks
    Replies: 15
    Last Post: 11-25-2007, 04:25 AM
  4. [Release] Simple super jump trainer
    By dezer in forum WarRock - International Hacks
    Replies: 19
    Last Post: 07-12-2007, 05:22 PM
  5. [RELEASE] Simple Weapon Hack
    By Naeron in forum WarRock - International Hacks
    Replies: 51
    Last Post: 06-05-2007, 07:17 PM

Tags for this Thread