Array - Strings of Characters.
-
Please, what´s wrong?? Why the variable "xyz[1]" don´t assigning value "1"??? #include "windows.h" #include "stdio.h" #include "iostream.h" #include "string.h" #include "stdlib.h" char palav[8]; char xyz[6]; void main() { //(......) cout << "\n\n\nWrite a word : "; cin.getline (palav, 8, '\n'); switch (palav[0]) { case '"A"': xyz[1] = "1" case '"B"': xyz[1] = "2"; case '"C"': xyz[1] = "3"; case '"D"': xyz[1] = "4"; case '"E"': xyz[1] = "5"; case '"F"': xyz[1] = "6"; case '"G"': xyz[1] = "7"; case '"H"': xyz[1] = "8"; case '"I"': xyz[1] = "9"; case '"J"': xyz[1] = "0"; } cout << "Caracter1 " << xyz[1] << endl; //(.....) } erro: error C2440: '=' : cannot convert from 'char [1]' to 'char' This conversion requires a reinterpret_cast, a C-style cast or function-style cast. raf-sp@bol.com.br
-
Please, what´s wrong?? Why the variable "xyz[1]" don´t assigning value "1"??? #include "windows.h" #include "stdio.h" #include "iostream.h" #include "string.h" #include "stdlib.h" char palav[8]; char xyz[6]; void main() { //(......) cout << "\n\n\nWrite a word : "; cin.getline (palav, 8, '\n'); switch (palav[0]) { case '"A"': xyz[1] = "1" case '"B"': xyz[1] = "2"; case '"C"': xyz[1] = "3"; case '"D"': xyz[1] = "4"; case '"E"': xyz[1] = "5"; case '"F"': xyz[1] = "6"; case '"G"': xyz[1] = "7"; case '"H"': xyz[1] = "8"; case '"I"': xyz[1] = "9"; case '"J"': xyz[1] = "0"; } cout << "Caracter1 " << xyz[1] << endl; //(.....) } erro: error C2440: '=' : cannot convert from 'char [1]' to 'char' This conversion requires a reinterpret_cast, a C-style cast or function-style cast. raf-sp@bol.com.br
-
Please, what´s wrong?? Why the variable "xyz[1]" don´t assigning value "1"??? #include "windows.h" #include "stdio.h" #include "iostream.h" #include "string.h" #include "stdlib.h" char palav[8]; char xyz[6]; void main() { //(......) cout << "\n\n\nWrite a word : "; cin.getline (palav, 8, '\n'); switch (palav[0]) { case '"A"': xyz[1] = "1" case '"B"': xyz[1] = "2"; case '"C"': xyz[1] = "3"; case '"D"': xyz[1] = "4"; case '"E"': xyz[1] = "5"; case '"F"': xyz[1] = "6"; case '"G"': xyz[1] = "7"; case '"H"': xyz[1] = "8"; case '"I"': xyz[1] = "9"; case '"J"': xyz[1] = "0"; } cout << "Caracter1 " << xyz[1] << endl; //(.....) } erro: error C2440: '=' : cannot convert from 'char [1]' to 'char' This conversion requires a reinterpret_cast, a C-style cast or function-style cast. raf-sp@bol.com.br
This code should not have compile without errors. CORRECTION: switch (palav[0]) { case 'A': xyz[1] = '1' break; case 'B': xyz[1] = '2'; break; case 'C': xyz[1] = '3'; case 'D': break; xyz[1] = '4'; case 'E': break; xyz[1] = '5'; break; case 'F': xyz[1] = '6'; break; case 'G': xyz[1] = '7'; break; case 'H': xyz[1] = '8'; break; case 'I': xyz[1] = '9'; break; case 'J': xyz[1] = '0'; break; } INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen
-
This code should not have compile without errors. CORRECTION: switch (palav[0]) { case 'A': xyz[1] = '1' break; case 'B': xyz[1] = '2'; break; case 'C': xyz[1] = '3'; case 'D': break; xyz[1] = '4'; case 'E': break; xyz[1] = '5'; break; case 'F': xyz[1] = '6'; break; case 'G': xyz[1] = '7'; break; case 'H': xyz[1] = '8'; break; case 'I': xyz[1] = '9'; break; case 'J': xyz[1] = '0'; break; } INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen