Strings

This is a discussion on Strings within the C++ Programming forums, part of the General Programming Boards category; im having some troble declaring strings in Visual Studio .Net, could some one please give me the standard form for ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    24

    Strings

    im having some troble declaring strings in Visual Studio .Net, could some one please give me the standard form for this in .Net. Im using the strings lib. any help would be great... thanks in advance

  2. #2
    Registered User The Dog's Avatar
    Join Date
    May 2002
    Location
    Cape Town
    Posts
    788
    Code:
    string s; //A reference
    s = new string();
    //edit
    sorry, that was c# code
    Last edited by The Dog; 05-22-2003 at 05:38 PM.

  3. #3
    RoD
    RoD is offline
    Redundantly Redundant RoD's Avatar
    Join Date
    Sep 2002
    Location
    Missouri
    Posts
    6,331
    Code:
    /*	I had things on my mind so this
    	was a good way to help you and get
    	them off for a bit
    */
    #include <iostream>
    #include <string>
    
    using namespace std;
    
    int main() 
    {
    	/*	Declare a string of un-specified
    		length. We can also do string userName[sumvalue]
    	*/
    	string userName;
    
    	/*	Read in the string from user
    	*/
    	cout << "Your Name: ";
    	cin >> userName; 
    
    	/*	As is
    	*/
    	cout << "Original string: " << userName << endl;
    
    	/*	Check to see if the first letter in
    		string is lowercase. If it is, lets 
    		capitalize it!
    	*/
    	if((userName[0] > 97) && (userName[0] < 122))
    	 {
    		userName[0] -= 32;
    	 }
    
    	/*	Changed
    	*/
    	cout << "Capitalized: " << userName << endl;
    
    	return 0;
    }

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    We can also do string userName[sumvalue]
    You are aware that this declares an array of strings, right?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

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, 02:24 PM
  2. Programming using strings
    By jlu0418 in forum C++ Programming
    Replies: 5
    Last Post: 11-26-2006, 07: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21