Thread: strings

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Aug 2005
    Posts
    266

    strings

    look at my code,
    what is held in name[7]? a null? or random information?
    for example,,,how would i get it to print letter by letter till it reachs the end of my name , rodrigo. ? without directly telling it to stop at name[6]?
    Code:
    #include <string>
    #include <iostream>
    #include <conio.h>
    using namespace std;
    int main()
    {
         string name("rodrigo");
         cout << name[7]; 
         getch();
         }
    i tried this to find out what name[7] was holding but prints nothing.
    -
    i have tried this but i have no idea what i was doing,, lol
    Code:
    #include <string>
    #include <iostream>
    #include <conio.h>
    using namespace std;
    int main()
    {
         string name("rodrigo");
         for(int x=0; x!=NULL;x++){
         cout << name[x]; 
         endl;
         
         }
         getch();
         }
    Last edited by rodrigorules; 06-07-2006 at 06:36 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strings Program
    By limergal in forum C++ Programming
    Replies: 4
    Last Post: 12-02-2006, 03:24 PM
  2. Programming using strings
    By jlu0418 in forum C++ Programming
    Replies: 5
    Last Post: 11-26-2006, 08:07 PM
  3. Reading strings input by the user...
    By Cmuppet in forum C Programming
    Replies: 13
    Last Post: 07-21-2004, 06:37 AM
  4. damn strings
    By jmzl666 in forum C Programming
    Replies: 10
    Last Post: 06-24-2002, 02:09 AM
  5. menus and strings
    By garycastillo in forum C Programming
    Replies: 3
    Last Post: 04-29-2002, 11:23 AM