User Tag List

Results 1 to 6 of 6

Thread: 2 String Example In C++

  1. #1
    2 String Example In C++

    User Info Menu

    2 String Example In C++

    Thanks to Evil Loco

    Name String/Show Date

    Code:
     #include <iostream>
     #include <string>
     #include <stdio.h>
     
     int day, month, year;
     char info[] = "05/09/2010";
     
     using namespace std;
     
     int main()
     {
                     system("title Bl4Ck.KiD...'s String Program");
                    system("color 9c");
                    cout << "Bl4Ck.KiD...'s String Program\n\n";
             cout << "Type Your Name Here: ";
             string full_name;
             getline( cin, full_name );
             int middle = full_name.size() / 2;
             
             string greeting = "\nHello " + full_name + ", Ima Bob ";
             cout << greeting << "Nice To Meet You, \n" <<  endl
                      << full_name << " The Date Today Is... \n"
                      <<endl;
     
             
                      sscanf(info, "%d/%d/%d", &day, &month,  &year);
             
                    printf("Day: %d\n",day);
                     printf("Month: %d\n",month);
                     printf("Year: %d\n",year);
                     
                                           system("pause");
                                           std::getchar();
                                               return 0;
                                           }
    Date/Month/Year String Still A Lil Messed Up But Ill Fix Later

    Code:
     #include <iostream>
     #include <string>
     #include <stdio.h>
     
     using namespace std;
     
     int main()
     {
                     system("title Bl4Ck.KiD...'s String Program");
                     system("color 9c");
                    cout << "Bl4Ck.KiD...'s String Program\n\n";
             cout << "Type What Number Day Is It Here: \n" <<  endl;
             cout << "Type What Month It Is Here: \n" <<endl;
             cout << "Type What Year It Is Here: \n" <<endl;
             string day;
             string month;
             string year;
             getline( cin, day );
             getline( cin, month );
             getline( cin, year );
             int first = day.size() / 2;
             int middle = month.size() / 2;
             int end = year.size() / 2;
             
             string greeting = day + "/" + month + "/" + year;
             cout << greeting << "\n Thats What It Is Today \n"  << endl;
     
                                           system("pause");
                                           std::getchar();
                                               return 0;
                                           }
    Get At Me Bl4Ck.KiD... Aka BK
    Future Rapper - Spits Fire
    Psp Coder - Mips, C
    Web Designer - HTML, Javascript, Some PHP
    Computer Programmer - Currently Learning C/C++, Visual Basic, Pascal, Brainfuck, Python, Ruby

  2. #2
    2 String Example In C++

    User Info Menu

    Re: 2 String Example In C++

    ok. So I see you've "mastered" the basics. Let's see something kick ass from you next!

  3. #3
    2 String Example In C++

    User Info Menu

    Re: 2 String Example In C++

    What do you have in mind, I'm think about learnin 2D arrays an some other array stuff next
    Get At Me Bl4Ck.KiD... Aka BK
    Future Rapper - Spits Fire
    Psp Coder - Mips, C
    Web Designer - HTML, Javascript, Some PHP
    Computer Programmer - Currently Learning C/C++, Visual Basic, Pascal, Brainfuck, Python, Ruby

  4. #4
    2 String Example In C++

    User Info Menu

    Re: 2 String Example In C++

    Quote Originally Posted by Bl4Ck.KiD... View Post
    What do you have in mind, I'm think about learnin 2D arrays an some other array stuff next
    Let's see you dick around with matrices

  5. #5
    2 String Example In C++

    User Info Menu

    Re: 2 String Example In C++

    Quote Originally Posted by B1G_BR0TH3R View Post
    Let's see you dick around with matrices
    ok ill read up on it
    Get At Me Bl4Ck.KiD... Aka BK
    Future Rapper - Spits Fire
    Psp Coder - Mips, C
    Web Designer - HTML, Javascript, Some PHP
    Computer Programmer - Currently Learning C/C++, Visual Basic, Pascal, Brainfuck, Python, Ruby

  6. #6
    2 String Example In C++

    User Info Menu

    Re: 2 String Example In C++

    Code:
    #include <stdio.h>
    Is not needed.

    "std::" is also unnecessary because you declared the namespace to std. You only need to use the std class from the #include <iostream> when you don't have
    Code:
    using namespace std;
    Quote Originally Posted by Epic of HITB
    get... 1) a mini fridge | 2) A toilet installed in your room | 3) a closet full of non-perishable foods | 4) Lyscol ( who needs showers anyway?) | 5) tons of books articles lectures zines etc etc

    Dont leave your room...EVER... AND I MEAN EVER
    Damned six line limit! *NERD RAGE*

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •