Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > Standard C, C++

Reply
 
LinkBack Thread Tools Display Modes
Old 01-11-2003, 09:41 AM   #1 (permalink)
anon
Guest
 
Posts: n/a
Array of chars of chars of, wait, uh...

OK, I am trying to get an array of strings, and no I cannot do

char blah[100];

I want to have an array of STRINGS. Meaning I can call something like

blah[100];
and I will get something like "This is the 100th *string*". Now the problem is I have to have strings stored and not chars so is it possible to do this? I can just do a billion chars declared but thats no fun . I also dont want to have separate blocks, like blah[1-100] for this and blah[101-200] for this, I would rather have another way to do this but I don't know how



PS. Keep off-topic/non-helping posts *gone*
  Reply With Quote
Old 01-11-2003, 12:52 PM   #2 (permalink)
DesertWolf
Non-profit Techie
 
DesertWolf's Avatar
 
Join Date: Dec 2002
Location: Mesa AZ
Posts: 76
DesertWolf is on a distinguished road
Send a message via AIM to DesertWolf
Use a multidimentual array like this

char[number of string][string data];

I think that would do what you are looking for.

PS: is Ilya getting irritating?
DesertWolf is offline   Reply With Quote
Old 01-11-2003, 01:04 PM   #3 (permalink)
anon
Guest
 
Posts: n/a
Doh! Doh! Doh! How did I not think of that! Doh!

So I can just do:

char blah[100][100];

and will the info in the first dimension be kept? (in JS it is wiped :butt: ) But arg! I can't believe I didn't think of that!

Thanks :o <-- *An embarrased Vlad *
  Reply With Quote
Old 01-11-2003, 03:36 PM   #4 (permalink)
DesertWolf
Non-profit Techie
 
DesertWolf's Avatar
 
Join Date: Dec 2002
Location: Mesa AZ
Posts: 76
DesertWolf is on a distinguished road
Send a message via AIM to DesertWolf
I would use the first array as an index for my second array that would hold the string info.
It will be kept in C++, Java and Cocoa I haven't done JS so I don't know about that.
DesertWolf is offline   Reply With Quote
Old 01-11-2003, 03:38 PM   #5 (permalink)
anon
Guest
 
Posts: n/a
Quote:
Originally posted by DesertWolf
I would use the first array as an index for my second array that would hold the string info.
Well all I need to do is just be able to call a string, I don't really have info in the first array. But a good suggestion
  Reply With Quote
Old 01-11-2003, 03:42 PM   #6 (permalink)
DesertWolf
Non-profit Techie
 
DesertWolf's Avatar
 
Join Date: Dec 2002
Location: Mesa AZ
Posts: 76
DesertWolf is on a distinguished road
Send a message via AIM to DesertWolf
Really won't make much diffence unless you are going to be doing any sorting on the array.
DesertWolf is offline   Reply With Quote
Old 01-11-2003, 03:44 PM   #7 (permalink)
anon
Guest
 
Posts: n/a
Quote:
Originally posted by DesertWolf
Really won't make much diffence unless you are going to be doing any sorting on the array.
Actually I could hold the size of the string in the first array. Not a bad idea.


PS. Just so you know, I am working on porting something from JS to C, and I could just use normal old Arrays in JS by doing new Array() and forgot how to in C.
  Reply With Quote
Old 01-11-2003, 03:58 PM   #8 (permalink)
DesertWolf
Non-profit Techie
 
DesertWolf's Avatar
 
Join Date: Dec 2002
Location: Mesa AZ
Posts: 76
DesertWolf is on a distinguished road
Send a message via AIM to DesertWolf
What OS are you porting too? MS or Linux?
DesertWolf is offline   Reply With Quote
Old 01-11-2003, 04:00 PM   #9 (permalink)
anon
Guest
 
Posts: n/a
Quote:
Originally posted by DesertWolf
What OS are you porting too? MS or Linux?
Not OS, I am porting from language to language, because right now JS only works in web browsers but I want to be able to access it in CLI (because I am learning C and need to learn stuff...) But the JS should work on all OS's with a JS compatible browser and the C should work on UNIX, althought if it works on M$ O$ too that wouldn't be bad
  Reply With Quote
Old 01-11-2003, 04:06 PM   #10 (permalink)
DesertWolf
Non-profit Techie
 
DesertWolf's Avatar
 
Join Date: Dec 2002
Location: Mesa AZ
Posts: 76
DesertWolf is on a distinguished road
Send a message via AIM to DesertWolf
Well to make things easier on yourself, you could use the <string.h> or <string> if you are using namespaces. then you could just use an array of strings and not worry about that char as string BS. try this site.
http://www.experts-exchange.com/Prog..._10355710.html

It might help.
DesertWolf is offline   Reply With Quote
Old 01-11-2003, 04:09 PM   #11 (permalink)
Ilya020
Techno Rat
 
Ilya020's Avatar
 
Join Date: Jan 2003
Location: San Diego
Posts: 559
Ilya020 is on a distinguished road
Send a message via AIM to Ilya020
nice site...
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Old 01-11-2003, 04:09 PM   #12 (permalink)
anon
Guest
 
Posts: n/a
OK, thanks, I'll check them out and see if they help. I am probably going to be writing AALLOOTT of functions... Because I need to learn But thanks,

<strange rambling>
Thank god for getchar, because it gets the value of the input in the UNICODE value :rock: If you have no idea what I am talking about, it may be because you need to see the program to get it
  Reply With Quote
Old 01-11-2003, 04:10 PM   #13 (permalink)
Ilya020
Techno Rat
 
Ilya020's Avatar
 
Join Date: Jan 2003
Location: San Diego
Posts: 559
Ilya020 is on a distinguished road
Send a message via AIM to Ilya020
wait, is your encryption/decryption program?
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Old 01-11-2003, 04:11 PM   #14 (permalink)
anon
Guest
 
Posts: n/a
Quote:
Originally posted by ilya020
wait, is your encryption/decryption program?
If thats what you want to call it (it sucks!) If you want I can paste the URL here so every can have a good laugh at the source
  Reply With Quote
Old 01-11-2003, 04:12 PM   #15 (permalink)
Ilya020
Techno Rat
 
Ilya020's Avatar
 
Join Date: Jan 2003
Location: San Diego
Posts: 559
Ilya020 is on a distinguished road
Send a message via AIM to Ilya020
sure, I need some cheering up

Ilya
__________________
> SELECT * FROM users WHERE clue > 0
0 rows returned
Ilya020 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
working with Array Goong MS Technologies ( ASP, VB, C#, .NET ) 3 07-22-2004 12:14 PM
breaking down an array from a form metazai PHP 12 07-09-2004 06:18 AM
array max num Apodysophilia Java 9 04-10-2003 06:36 AM
Return an array with register_globals = off bdl PHP 7 03-10-2003 05:37 PM
adding to an array in php sde PHP 1 06-12-2002 11:04 AM


All times are GMT -8. The time now is 11:42 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting