Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C++
Expertise: Beginner
May 19, 2000

Accessing the Address of a String Element

Question:
In the following code, how do I get the address of the first character of str in the function discard?
discard(string *name)
{ 
//..
}
int main()
{ 
  string str;
  cin >> str;
  discard(str);
  return(0);
}

Answer:
It's simple: &str[0] returns the address of the first character of the string object.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date