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. functions and arrays

functions and arrays

Scheduled Pinned Locked Moved C / C++ / MFC
data-structureshelpquestion
5 Posts 2 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.
  • S Offline
    S Offline
    Steve Severance
    wrote on last edited by
    #1

    I need to pass an array to a function. When the array is one dimensional it works. When I try to use two dimensions it doesn't work. What can I do to fix this? Steve Not all who wander are lost...

    N 1 Reply Last reply
    0
    • S Steve Severance

      I need to pass an array to a function. When the array is one dimensional it works. When I try to use two dimensions it doesn't work. What can I do to fix this? Steve Not all who wander are lost...

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #2

      You should pass the char** and not the char* Nish p.s. show some code too._


      One little CD gone, Then two CDs gone, Then 5 more gone, For a total 7 gones, If I was a CD R, I'd wanna cry, Cause I'd be just a goner, For a nasty CD burner. [funny how frustration wakes up the poet in me]_

      S 1 Reply Last reply
      0
      • N Nish Nishant

        You should pass the char** and not the char* Nish p.s. show some code too._


        One little CD gone, Then two CDs gone, Then 5 more gone, For a total 7 gones, If I was a CD R, I'd wanna cry, Cause I'd be just a goner, For a nasty CD burner. [funny how frustration wakes up the poet in me]_

        S Offline
        S Offline
        Steve Severance
        wrote on last edited by
        #3

        Thanks. the function is as follows. (don't comment on the lack of use of language features. I am not allowed to use them on this project.) is there a way to do it without using char **? [code] void BuildBoard(char *arBoard[], int Rows, int Cols) { int inRows,inCols; char inChar; for(inRows = 0;inRows < Rows;inRows++) { for(inCols = 0;inCols < Cols;inCols++) { scanf("%c",&inChar); arBoard[inCols][inRows] = inChar; } } return; } [/code] Steve Not all who wander are lost...

        N 1 Reply Last reply
        0
        • S Steve Severance

          Thanks. the function is as follows. (don't comment on the lack of use of language features. I am not allowed to use them on this project.) is there a way to do it without using char **? [code] void BuildBoard(char *arBoard[], int Rows, int Cols) { int inRows,inCols; char inChar; for(inRows = 0;inRows < Rows;inRows++) { for(inCols = 0;inCols < Cols;inCols++) { scanf("%c",&inChar); arBoard[inCols][inRows] = inChar; } } return; } [/code] Steve Not all who wander are lost...

          N Offline
          N Offline
          Nish Nishant
          wrote on last edited by
          #4

          And how are you calling the function? What are you passing as the first arg? Nish_


          One little CD gone, Then two CDs gone, Then 5 more gone, For a total 7 gones, If I was a CD R, I'd wanna cry, Cause I'd be just a goner, For a nasty CD burner. [funny how frustration wakes up the poet in me]_

          S 1 Reply Last reply
          0
          • N Nish Nishant

            And how are you calling the function? What are you passing as the first arg? Nish_


            One little CD gone, Then two CDs gone, Then 5 more gone, For a total 7 gones, If I was a CD R, I'd wanna cry, Cause I'd be just a goner, For a nasty CD burner. [funny how frustration wakes up the poet in me]_

            S Offline
            S Offline
            Steve Severance
            wrote on last edited by
            #5

            int Rows, Cols;//I already have the vales for these char Board[100][50]; BuildBoard((char **)Board,Rows,Cols); I need to be able to do this without using the typecast and without making Board a char *. Thanks. Steve Not all who wander are lost...

            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