Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 04-25-2007, 08:15 PM   #1
Member (10 bit)
 
faint545's Avatar
 
Join Date: Mar 2006
Location: Maryland
Posts: 550
Exclamation Passing a 2 dimensional array through a function

Quick question here.

How do you pass a two-dimensional array containing characters through a function?
I keep getting this
Quote:
error 26 C:\Dev-Cpp\Projects\project8.cpp cannot convert `char (*)[10]' to `char*' for argument ` 1' to `void phase2(char*, int)'
this is what i have..
Quote:
void phase2(char [], int);

int main()
{
const int rows = 12, colums = 10;
char months[rows][colums] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
phase2(months, rows);
return 0;
}

void phase2(char all_months[], int month_postition)
{
cout << "I'm in phase 2";
}
__________________
Kerberos2:
Corsair Obsidian 700D
ASUS M4A89TD
Radeon HD 5850
A-DATA 8GB DDR3 1333
AMD Phenom II x6 1055T @ 2.8GHz w/ Corsair H50
Corsair 850HX PSU
WD Blue 160GB 7200 RPM SATA HDD
WD Black 640GB 7200 RPM SATA HDD
ASUS DVD/CD Drive
faint545 is offline   Reply With Quote
Old 04-27-2007, 10:13 PM   #2
Moderator
Staff
Premium Member
 
Join Date: Aug 2003
Location: Richmond, VA
Posts: 7,835
Perhaps you will need to change the argument-type for the function from a one-dimensional array to a two-dimensional array? Instead of:
PHP Code:
void phase2(char all_month[], int month_position
Try:
PHP Code:
void phase2(char all_month[][cols]) 
Be sure to change the appropriate prototype for the function as well to reflect the changes you've made within the function.

kram
__________________
"For today, goodbye. For tomorrow, good luck. And forever, Go Blue!"
University of Michigan President Mary Sue Coleman
kram 2.0 is offline   Reply With Quote
Old 04-27-2007, 10:55 PM   #3
Barefoot on the Moon!
Staff
Premium Member
 
Force Flow's Avatar
 
Join Date: Aug 2002
Location: Northeastern USA
Posts: 13,385
I'm not familar with C++, and may be making a few assumptions about the language, but shouldn't you be using string instead of char?
__________________
There are two secrets to staying young, being happy, and achieving success. You have to laugh and find humor every day, and you have to have a dream.
Force Flow is offline   Reply With Quote
Old 04-29-2007, 04:58 AM   #4
Member (8 bit)
 
Rapier's Avatar
 
Join Date: May 2001
Location: Runnemede NJ
Posts: 236
Send a message via AIM to Rapier
splat

Quote:
Originally Posted by faint545
Quick question here.

How do you pass a two-dimensional array containing characters through a function?
I keep getting this
this is what i have..

Wow! I'll bet that hurt.
__________________
Women are better people, Men are better men

Windows XP Home Edition Service Pack 2 (build 2600) Dell E521 1.90 gigahertz AMD Athlon 64 X2 Dual Core
PHILIPS DVD-ROM
TEAC USB HS-CF Card Device
WDC WD800JD-75MSA3 [Hard drive] (80.00 GB) -- drive 0, s/n
WD-WMAM9KL69938, rev 10.01E04, SMART Status: Healthy 2048 Megabytes
NVIDIA nForce 430/410 Serial ATA Cntl(2x) NVIDIA GeForce
7300 LE[Display adapter]Soyo 24" Widescreen LCD Monitor 24D6

Processor Intel Pentium III, 501 MHz
System Board ICO Peripherals, Inc. Intel 440ZX
BIOS ASl, Inc. 4.51 PG 06/03/99 Chipset Intel 82443BX
Memory 512 MB Memory Type 256+256;|DIMM|SDRAM|;T5
Video board S3 Graphics Inc. Savage4
Video mode 800x600, 32 bits/pixel
XP 5.1.2600
Rapier is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Computer Acronyms Floppyman Computer Hardware 156 06-18-2006 06:25 AM
VBA: ending a function within an if statement jong2k4 Web Design / Development 3 07-05-2005 02:55 PM
external js file and repeated function craigtaylor74 Web Design / Development 0 03-13-2005 07:30 AM
C++ Function by Refrence (Passing Parameters by reference) HNPFL Web Design / Development 2 02-15-2005 04:02 PM
Overclock Suggestions? ShannonLi Computer Hardware 9 08-04-2004 11:24 AM


All times are GMT -5. The time now is 07:28 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2