|
From: carlos D. M. <cg...@wo...> - 2001-12-07 18:36:12
|
Exuss Draugas escribió: > Hi All! > > Just a simple question. How to assing a value to array of char? > > char myValue[20] = "Some text!"; > cout << myValue << endl; > > // This is don't work :(( > myValue="New text"; > > Works only: cin >> myValue; > > Thanks, > > Exuss > > -- > Nemokama el.paðto dëþutë - http://webmail.delfi.lt/ > > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users Use strcpy(myvalue, "Some text"); This pass the second value to the first variable. And this works with spaces. If the second is "Hello marvellous world", myvalue will be the whole phrase, not only the first word. cin >>myvalue; would put in myvalue "Hello", only. Then, for input from keyboard you need use cin.getline(char array, size of the char array); cin.getline(myValue, 20); **input: Hello baby** will put in myValue "Hello baby". |