Showing posts with label Notes. Show all posts
Showing posts with label Notes. Show all posts

[note] convert char to int in a string

11:01 AM at 11:01 AM

#include
#include

using namespace std;

int main()
{

//Some string here
string number = "123456789";

//Array to hold the separate integers
int intArray[ number.length() ];

//Convert from char to int
for ( int i=0; i < i="0;">

[note] read file data to string, by char

11:00 AM at 11:00 AM

#include
#include

using namespace std;

int main()
{

ifstream inputFile;
inputFile.open("some file name here");

string number;
char digit;

while( inputFile.get( digit ) )
{

number = number + digit;

}

return 0;

}

[note] pointer class function

10:55 AM at 10:55 AM

class myclass
{
node IPlist::*find (string address) const;
}

//the notation should be :

node* IPlist::find (string address) const
{
...
}

[note] Compare string

10:50 AM at 10:50 AM

//string can be compared directly, even it has "." or "@" symbols inside
#include
int main()
{
std::string a;
std::string b;
if ( a == b )
{
cout << "a is equal to b"; } }

C++ Forum

10:31 AM at 10:31 AM

I found a very good c++ forum, http://www.codeguru.com/forum/ in there, peoples gave me very fast and professional replys.