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. Could ya'll please tell me what is wrong with this code?

Could ya'll please tell me what is wrong with this code?

Scheduled Pinned Locked Moved C / C++ / MFC
questioncsharpc++visual-studiohelp
5 Posts 4 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.
  • E Offline
    E Offline
    Ever1234
    wrote on last edited by
    #1

    Okay, it isnt done yet and this is the first time I have ever used arrays. Visual Studio 6.0 gave me 21 errors, and I dont know how to fix it. heres the code: // Password Generator.cpp : Randomly generates an 8 charactor password. //with swapping vowls and consenents for maximum pronounciblity. #include "stdafx.h" int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // TODO: Place code here. char cons[19]; char vowl[6]; int number[10]; cons[0]="b" || "B"; cons[1]="c" || "C"; cons[2]="d" || "D"; cons[3]="f" || "F"; cons[4]="g" || "G"; cons[5]="h" || "H"; cons[6]="j" || "J"; cons[7]="k" || "K"; cons[8]="l" || "L"; cons[9]="m" || "M"; cons[10]="n" || "N"; cons[11]="p" || "P"; cons[12]="r" || "R"; cons[13]="s" || "S"; cons[14]="t" || "T"; cons[15]="v" || "V"; cons[16]="w" || "W"; cons[17]="x" || "X"; cons[18]="z" || "Z"; vowl[0]="a" || "A"; vowl[1]="e" || "E"; vowl[2]="i" || "I"; vowl[3]="o" || "O"; vowl[4]="u" || "U"; vowl[5]="y" || "Y"; int number[0]="1"; int number[1]="2"; int number[2]="3"; int number[3]="4"; int number[4]="5"; int number[5]="6"; int number[6]="7"; int number[7]="8"; int number[8]="9"; int number[9]="0"; return 0; } "To wonder is to begin to understand"

    R R 2 Replies Last reply
    0
    • E Ever1234

      Okay, it isnt done yet and this is the first time I have ever used arrays. Visual Studio 6.0 gave me 21 errors, and I dont know how to fix it. heres the code: // Password Generator.cpp : Randomly generates an 8 charactor password. //with swapping vowls and consenents for maximum pronounciblity. #include "stdafx.h" int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // TODO: Place code here. char cons[19]; char vowl[6]; int number[10]; cons[0]="b" || "B"; cons[1]="c" || "C"; cons[2]="d" || "D"; cons[3]="f" || "F"; cons[4]="g" || "G"; cons[5]="h" || "H"; cons[6]="j" || "J"; cons[7]="k" || "K"; cons[8]="l" || "L"; cons[9]="m" || "M"; cons[10]="n" || "N"; cons[11]="p" || "P"; cons[12]="r" || "R"; cons[13]="s" || "S"; cons[14]="t" || "T"; cons[15]="v" || "V"; cons[16]="w" || "W"; cons[17]="x" || "X"; cons[18]="z" || "Z"; vowl[0]="a" || "A"; vowl[1]="e" || "E"; vowl[2]="i" || "I"; vowl[3]="o" || "O"; vowl[4]="u" || "U"; vowl[5]="y" || "Y"; int number[0]="1"; int number[1]="2"; int number[2]="3"; int number[3]="4"; int number[4]="5"; int number[5]="6"; int number[6]="7"; int number[7]="8"; int number[8]="9"; int number[9]="0"; return 0; } "To wonder is to begin to understand"

      R Offline
      R Offline
      Rick York
      wrote on last edited by
      #2

      First, cons is declared as an array of 19 characters. You are attempting set each item to a string logically or-ed with another string. The or-ed strings will result logically in a just a one. You probably want to set them to single character value so use the single quotes around each one. This applies to vowl also. Second, number is already declared as an array of 10 integers. You have an int in front of each use of them. Also, you probably don't want to set each entry in the int array to a string. To set each one to an integer value you need to lose the double quotes.

      1 Reply Last reply
      0
      • E Ever1234

        Okay, it isnt done yet and this is the first time I have ever used arrays. Visual Studio 6.0 gave me 21 errors, and I dont know how to fix it. heres the code: // Password Generator.cpp : Randomly generates an 8 charactor password. //with swapping vowls and consenents for maximum pronounciblity. #include "stdafx.h" int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // TODO: Place code here. char cons[19]; char vowl[6]; int number[10]; cons[0]="b" || "B"; cons[1]="c" || "C"; cons[2]="d" || "D"; cons[3]="f" || "F"; cons[4]="g" || "G"; cons[5]="h" || "H"; cons[6]="j" || "J"; cons[7]="k" || "K"; cons[8]="l" || "L"; cons[9]="m" || "M"; cons[10]="n" || "N"; cons[11]="p" || "P"; cons[12]="r" || "R"; cons[13]="s" || "S"; cons[14]="t" || "T"; cons[15]="v" || "V"; cons[16]="w" || "W"; cons[17]="x" || "X"; cons[18]="z" || "Z"; vowl[0]="a" || "A"; vowl[1]="e" || "E"; vowl[2]="i" || "I"; vowl[3]="o" || "O"; vowl[4]="u" || "U"; vowl[5]="y" || "Y"; int number[0]="1"; int number[1]="2"; int number[2]="3"; int number[3]="4"; int number[4]="5"; int number[5]="6"; int number[6]="7"; int number[7]="8"; int number[8]="9"; int number[9]="0"; return 0; } "To wonder is to begin to understand"

        R Offline
        R Offline
        Ravi Bhavnani
        wrote on last edited by
        #3

        If you're new to arrays, I assume you're relatively new to programming. In which case, you should be creating console apps, not Win apps. Replace the WinMain() function with a standard C-style main(). Also, you should use the "Console application" in App Wizard. /ravi "There is always one more bug..." ravib@ravib.com http://www.ravib.com

        E 1 Reply Last reply
        0
        • R Ravi Bhavnani

          If you're new to arrays, I assume you're relatively new to programming. In which case, you should be creating console apps, not Win apps. Replace the WinMain() function with a standard C-style main(). Also, you should use the "Console application" in App Wizard. /ravi "There is always one more bug..." ravib@ravib.com http://www.ravib.com

          E Offline
          E Offline
          Ever1234
          wrote on last edited by
          #4

          okay, what does this mean? error C2440: '=' : cannot convert from 'char [2]' to 'char' I got 25 of these for that code. "To wonder is to begin to understand"

          T 1 Reply Last reply
          0
          • E Ever1234

            okay, what does this mean? error C2440: '=' : cannot convert from 'char [2]' to 'char' I got 25 of these for that code. "To wonder is to begin to understand"

            T Offline
            T Offline
            Tim Smith
            wrote on last edited by
            #5

            "b" is a character string of length 2. If you want just the character 'b', then use single quotes. Tim Smith Descartes Systems Sciences, Inc.

            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