Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Array - Strings of Characters.

Array - Strings of Characters.

Scheduled Pinned Locked Moved C / C++ / MFC
sharepointcomdata-structureshelpquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    raf sp
    wrote on last edited by
    #1

    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

    S J 2 Replies Last reply
    0
    • R raf sp

      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

      S Offline
      S Offline
      suiram40
      wrote on last edited by
      #2

      xyz[1] = '1'; not xyz[1] = "1";

      1 Reply Last reply
      0
      • R raf sp

        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

        J Offline
        J Offline
        John R Shaw
        wrote on last edited by
        #3

        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

        R 1 Reply Last reply
        0
        • J John R Shaw

          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

          R Offline
          R Offline
          raf sp
          wrote on last edited by
          #4

          Thank´s!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1111 :):):-D

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups