3 Replies - 2494 Views - Last Post: 27 November 2009 - 07:46 PM Rate Topic: -----

#1 liop  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 22-February 09

convert from string to char

Posted 27 November 2009 - 06:49 PM

firstName_ is a data member

void Student::setFirstName ( string FName )
{

strcpy(firstName_,FName );

}
Is This A Good Question/Topic? 0
  • +

Replies To: convert from string to char

#2 nathanpc  Icon User is offline

  • SCIENCE!
  • member icon

Reputation: 113
  • View blog
  • Posts: 1,171
  • Joined: 31-July 09

Re: convert from string to char

Posted 27 November 2009 - 07:06 PM

Put the code tags and also put more details!
void Student::setFirstName ( string FName )
{
   strcpy(firstName_,FName );
}

Was This Post Helpful? 0
  • +
  • -

#3 liop  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 22-February 09

Re: convert from string to char

Posted 27 November 2009 - 07:27 PM

i want to convert from string to char

[/

char firstName_[15] //is a data member

void Student::setFirstName ( string FName )
{

strcpy(firstName_,FName );

}
]
Was This Post Helpful? 0
  • +
  • -

#4 Silhouette  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 11
  • Joined: 25-November 09

Re: convert from string to char

Posted 27 November 2009 - 07:46 PM

Just use the built in function, c_str()

stringObject.c_str(); //returns a constant c-string
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1