In c++, how do I convert a variable of char* type to Std::string type.?
151527
declare array e.g\n\nchar a[]={'1','2','3','x','y'};\n\nthere is no other functions to do it ansi C.\nu have to put it in an array. then its a string.
329906
I have some c++ serial port code that does what you want. Email me and I will send it to you. I have used it for a few apps. and it seems to work just fine.
326706
var\nP : Array[0..10,11..20] of Pointer;
359046
#include <ctype.h>\n#include <stdio.h>\n#include <stdlib.h>\n\nstatic char *article[] = { "the","a", "one", "some", "any" };\nstatic char *noun   [] = { "boy","girl", "dog", "town", "car" };\nstatic char *verb   [] = { "drove","jumped", "ran", "walked", "skipped" };\nstatic char *prep   [] = { "to", "from", "over", "under", "on" };\n\nint\nmain()\n{\n  int asize = sizeof(article)/sizeof(article[0]);\n  int nsize = sizeof(noun)/sizeof(noun[0]);\n  int vsize = sizeof(verb)/sizeof(verb[0]);\n  int psize = sizeof(prep)/sizeof(prep[0]);\n\n  char buff[100];\n  for (int i=0; i<20; i++) {\n    (void)sprintf(buff, "%s %s %s %s %s %s.",\n      article[rand()%asize],\n      noun[rand()%nsize],\n      verb[rand()%vsize],\n      prep[rand()%psize],\n      article[rand()%asize],\n      noun[rand()%nsize]);\n    *buff = toupper(*buff);\n    (void)printf("%s&#92;n", buff);\n  }\n  return 0;\n}\n\n\n$ a.out\nSome town walked to a dog.\nThe car ran from any dog.\nAny boy drove under any town.\nOne girl jumped under the girl.\nOne car jumped to one girl.\nAny boy skipped over a dog.\nAny town jumped from some town.\nThe town ran from the town.\nOne car walked to any town.\nOne town ran over one boy.\nAny town jumped on the car.\nSome dog skipped from a boy.\nSome girl skipped over a boy.\nA car walked over some girl.\nThe car jumped from a girl.\nThe boy skipped on the town.\nAny car walked from one girl.\nAny dog ran to a town.\nA car jumped under some car.\nSome boy walked to the car.
522101
void RemoveWhiteSpaces(char *string) {\nchar * bch;\nchar newstr[80];\n// Get the first whitespace\nbch = strtok (string,' ');\n\nwhile (*bch != '&#92;0')\n{\n  if(string != ' ') {\n   strcat(newstr,bch);\n  }\n  *bch++;\n}\n\nreturn 0;\n}\n\n\nI guess, I am not gonna give you the hwole answer, maybe I did :) But here it is, hope you the best.. Some stuff need work
74472
Use ToString() with a format, like ToString("#.00"), as in...\n\nDim test As Double\ntest = 0\nSystem.Console.WriteLine(test.ToString("#.00"))
509905
to_char function converts a value of DATE datatype to a value of VARCHAR2 (string) datatype. \n\nhttp://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/functions180.htm#i1009324\n\nfm - Returns a value with no leading or trailing blanks\n(without fm first character in returned value is blank)
438944
#include<stdio.h>\n#include<conio.h>\n#include<ctype.h>\n\nint main()\n{\n  char ch;\n  cout<<"enter some text&#92;n";\n  do{\n    ch=getch();\n    putchar(ch);\n  }while(ch!='&#92;n');\n  return 0;\n}
142433
you havn't closed "void determinecost (...)" function with curly braces " } "\n\nin c++, you have to close any block of code with } that has been opened with {
785470
There are numerous ways to do that. \nHere is, probably the simplest:\n\nchar *s="char *s=%c%s%c;%cmain() {printf(s,34,s,34,10,10);}%c";\nmain() {printf(s,34,s,34,10,10);}\n\nThe program itself is fairly useless.\nThe whole point of an exercise like this is the satisfaction of finding a solution yourself. Too bad, you did not give yourself a chance
2853
I always recommend Bjarne Stroustrup's "The C++ Programming Language", third edition.  It cuts straight to the meat of what is different between C and C++ instead of messing around with arrays of char like most tutorials do.
890450
char *Months[] = { "January", "February", "March", ... "December"};\n\nchar *GetMonth( int Index )\n{\n  return( Months[Index - 1] ); // Note -1 because first month is 1 not 0\n}
1047890
class C\n{\npublic:\nenum { NUM_VALUES = 10 };\n\nprivate:\ndouble m_values[NUM_VALUES];\n\npublic:\n// Sets the number stored at index i in m_values to v\nvoid SetValue(int i, double v) throw( std::exception )\n{\nif ( i < 0 || i >= NUM_VALUES ) throw std::exception("Index out of range");\nm_values[i] = v;\n}\n\n// Gets the number stored at index i in m_values\ndouble GetValue(int i) const throw( std::exception )\n{\nif ( i < 0 || i >= NUM_VALUES ) throw std::exception("Index out of range");\nreturn m_values[i];\n}\n\n    // Returns the mean of the numbers stored in m_values\n    double GetMean(void) const \n    {\n        double sum = 0;\n        for ( int i = 0; i < NUM_VALUES; i ++ ) sum += m_values[i];\n        return sum / NUM_VALUES;\n    }\n\n    // Returns the sample standard deviation of the numbers stored in m_values\n    double GetStandardDeviation(void) const \n    {\n        double mean = GetMean();\n        double sum = 0;\n        for ( int i = 0; i < NUM_VALUES; i ++ ) sum += (m_values[i]-mean)*(m_values[i]-mean);\n        return sqrt(sum/(NUM_VALUES-1));\n    }\n};
24515
int main()\n{\n   int age, feet, inches, pounds;\n   string hair, eye;\n}\n\n\nint means integer, string is something like "brown", "mary had a little lamb", etc\nyou can also do char to define a letter varible, or char can be used as a string by declaring a character array.
73050
Here is an example of how to do it in C++.\nAssume you want to use have a DLL named MyDll.dll, which contains a function, \n\nbool Function1(int)\n\n...\ntypedef bool Function1(int);\ntypedef Function1* pFunction1;\n\n...\n\nHMODULE DLLHandle;\nDLLHandle = LoadLibrary("MyDll.dll");\n\npFunction1 pF1 = (pFunction1)  GetProcAddress (DLLHandle,"Function1");\n...\nto call:\n   bool bSuccess = pF1(1);
665861
Objects declared const have a modified type whose value cannot be changed; they are read-only. For built-in types declared as const, this means that once initialized the compiler refuses to alter their values:\n\n  void inc( int& x ) { x +=1; } \n  const int i = 1;           // initialize constant value\n  i += 5;                    // error: 'i' is const\n  inc( i );                  // error: 'i' is const\nUsually, the const modifier comes immediately before the object it modifies. For example:\n\n  const int ZERO = 0;\n  const std::string msg( "Hello, World" );\nWhen applied to pointers, special attention should be paid to the placement of const. A pointer is a variable itself, so the placement of const often determines whether it applies directly to the pointer, to the object pointed to or to both. For example:\n\n  const std::string * str1 = &someString;\n  std::string const * str2 = &someString;\n  str2 = &anotherString;\nAbove, str1 is a pointer to a constant string. The const modifies the type std::string. Because there is no const * construct in C++, str2 also is a pointer to a constant string. Both str1 and str2 point to constant strings; therefore, it is impossible to alter the value of the strings they point to. However, it is possible to alter the pointers themselves, and indeed the str2 pointer is changed so that it points to another std::string. Deciphering these declarations can be difficult unless you read them backwards, from right to left. For example, the declaration of str1 can be read from right to left as "str1 is a pointer to a std::string which is const". And str2 can be read as "str2 is a pointer to a constant std::string". Although they are written differently, these declarations describe pointers of a similar type.\n\n  std::string * const str3 = &someString;\n  const std::string * const str4 = &someString;\nThe str3 variable demonstrates a pointer that is constant itself; the pointer value cannot be modified, although the argument pointed to can. It can be read as "str3 is a constant pointer to a std::string". Finally, str4 is the most extreme example. It can be read as "str4 is a constant pointer to a std::string which is const"; neither the pointer nor the string can be modified.\n\nConst Member Functions\nThe const modifier becomes a part of the object type and also can be applied to user-defined types:\n\n  class Invoice {    \n   public:\n   void giveDiscount( int d ) {\n    //...\n   }\n  };\n  const Invoice i;       // a constant user-defined object\n  i.giveDiscount();      // error: 'i' is const\nBecause Invoice::giveDiscount() has the potential to alter the internal state of the object, the compiler refuses to let you invoke this member function on i, which is declared as const. However, individual member functions themselves can be declared const, which tells the compiler that those member functions do not alter the internal state of the object and therefore are safe to invoke on const objects. For example:\n\n  class Invoice {                    \n   public:\n    int sum() const { // a constant member function\n     //...\n    }    \n  };\n  const Invoice i;    // declares a constant user-defined object\n  int s = i.sum();    // ok: Invoice::sum() is const\nC++ directly supports const as a language feature, so the compiler provides free compile-time checking of const objects. With properly designed interfaces that utilize const member functions, you are free to declare and use constant user-defined objects--only the const interface of those objects will be available. Designing interfaces that are const correct essentially boils down to declaring const member functions wherever possible. And these const member functions should be included early on in the design of your classes. Trying to retrofit them later often leads to a cascading effect throughout the applications that use your classes. It is much better to use
952303
Bcoz, the char itself returns the address...\nso no need for using '&' before it...