C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 31st, 2004, 11:45 PM
B-Con's Avatar
B-Con B-Con is offline
Crypto-Con
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Apr 2004
Location: Frisco, Texas
Posts: 6,704 B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 6 Days 6 h 45 m 21 sec
Reputation Power: 1235
Initialize a multi-dementional char array

Why doesn't this work?

char prompt[][]={{"String 1 here"},{"String 2 here"},{"And one last one...."}};

It keeps telling me that "elements of array prompt have incomplete type"....
__________________
- "Cryptographically secure linear feedback shift register based stream ciphers" -- a phrase that'll get any party started.
- Why know the ordinary when you can understand the extraordinary?
- Sponsor my caffeine addiction! (36.70 USD received so far -- Latest donor: Mark Foxvog.
)

Reply With Quote
  #2  
Old May 31st, 2004, 11:56 PM
The Dark The Dark is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2004
Location: Adelaide, Australia
Posts: 880 The Dark User rank is Lance Corporal (50 - 100 Reputation Level)The Dark User rank is Lance Corporal (50 - 100 Reputation Level)The Dark User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Day 14 h 15 m 25 sec
Reputation Power: 10
The inner dimension(s) of a multi-dimensional array need to be fixed, otherwise the compiler can't do its arithmetic to find the array elements.
Your declaration shoould be something like:
Code:
char prompt[][30]={{"String 1 here"},{"String 2 here"},{"And one last one...."}};

Note that this means you have to know the maximum length of the strings. Some compilers may give you an error if you get it wrong, but I wouldn't rely on that.
It will also allocate more space than you need.
Depending on what the array was for, you could use
Code:
char *prompt[]={"String 1 here","String 2 here","And one last one...."};

This just allocates enough space for the strings, but if you are modifying the data, it could be dangerous.

Reply With Quote
  #3  
Old June 1st, 2004, 01:17 AM
B-Con's Avatar
B-Con B-Con is offline
Crypto-Con
Dev Shed God 4th Plane (6500 - 6999 posts)
 
Join Date: Apr 2004
Location: Frisco, Texas
Posts: 6,704 B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level)B-Con User rank is General 4th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 6 Days 6 h 45 m 21 sec
Reputation Power: 1235
Ooohhh..... <smacks forhead>

thanx

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Initialize a multi-dementional char array

Developer Shed Advertisers and Affiliates



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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap