How the shit do you implement a string array in c++

how the shit do you implement a string array in c++

i just want to put a bunch of fucking words in a box for chrissake

stop making new threads, retard.

Either use a vector or just do
string variable[size]

char *arr;
arr = (char *) malloc(sizeof(char) * some_length + 1);

Dude, struggle.
Don't cheat for your homework. It's a bad habit. You learn by doing problems.

Fucking retard. This doesn't even compile!

just allocate some bytes for it bro

array of chars == array of strings?

Please don't graduate or shit up the job market with your inferior reasoning skills.

This is probably good advice all things considered.

This is also good advice, but it isn't for homework. I'm just fucking around with things I don't know yet out of curiosity.

Did this got segmentation fault for some reason. Ah well

Thanks bud

yes?
Honestly if you don't get this, and you need to be hand held with epic vectors, just learn java you fucktard.

A string in C is an array of chars.

So a string is held in a char array, since you only need 1 byte per character.

Read your textbook before asking basic questions.

>This is also good advice, but it isn't for homework. I'm just fucking around with things I don't know yet out of curiosity.
Don't lie.

He wants an array of strings, not just a string...

It's too late!!!

Fucking retard. You mean array of arrays of characters!

holy shit
Just imagine being this retarded for a second
Imagine.
>>>/java/

That's simple.

You need an array of char arrays.
char **arr = (char **) malloc(sizeof(char *) * num_strings);
unsigned i;
for (i = 0; i < num_strings; i++)
arr[i] = (char *) malloc(sizeof(char) * str_size + 1);

If you caught me I'd tell you I promise srsly
It was homework but then I had a silly idea after I turned it in and wanted to do ambitious things with it to see if I could.

For what it's worth this is very unlike me because I usually can't be assed to work on HW that's actually due but idk this is kinda fun I guess

Use a pointer array, in each position you have the begining of a liked list, each element of the linked list is a char.
That way you can have n words with different lenghts each.

Now, give me a ToLower function that uses **arr.

An array is a fixed size data structure.
std::string in c++ is not a fixed size data structure.
It is basically implemented as a vector of chars with some extra functions.

Consider using a vector of strings or a pointer to a string.

And if this doesn't work, implement your own string type so it works as you want to.

Reminder arrays of arrays are cancerous.

stop doing his fucking homework, faggot. You're contributing to the cancer that is currently flooding the programming industry.

>user we didnt teach this in class
>0/10

he's gonna fail anyway

JUST LOOK AT THESE RETARDS
WHY IS G SO SHIT
HERE U GO FAGGOT
char input
char min = 'A'
char max = 'Z'
char d = 'A' - 'a'
if(input >= min || input

Fucking retard. I have 65537 strings to store!

Don't you mean &&?

YES I DID
SORRY user

Now, use templates instead of char.

Sorry, I don't subscribe to bullshit gimmick programming.

why not use java, the most popular programming language in the planet? easier to implement a string array there too

it doesn't matter. Even just wasting time giving people like OP is degenerate. If OP is too damn lazy to learn, then ignore him and let him wonder off and die in the woods a lone. Nobody cares about people who aren't willing to bite the bullet and learn for themselves. What you are doing is not only letting these sub-human scums into the industry, but you're making them think it's ok they can just ask anyone to write code for them. Stop it.

Real talk tho I haven't posted outside of and And I actually worked it out around 18 mins ago anyway.
Some guy here is taking a really good opportunity to fuck with you all.

Just use Python, unless it's for homework. in that case KYS

What do you personally find appealing in Python?

Because a string array is just ['op', 'is', 'a', 'faggot']

list

that seems pretty simple desu

#include
#include

char
char_to_lower(char c)
{
char d = 'A' - 'a';
char min = 'A';
char max = 'Z';
if (c >= min && c = 0) {
ret[len] = char_to_lower(s[len]);
--len;
}
return ret;
}

int
main(int argc, char *argv[])
{
int len = 0;
while (argv[1][len] != '\0') {
len++;
}
char *lower = str_to_lower(argv[1], len);
printf(lower);
}

c is fun
>tfw program in swift all day

So, it's HW?
Dude keep doing this, relying on others, and you will grow up realizing you amount to nothing.

If OP is female, she can keep getting away with this pretty much forever, there's no shame in doing it when everyone expects nothing of you.

Lol, no they don't. Late 20s and they're old hags.

yes but by then you already snagged someone to take care of you financially

otherwise, you're basically a failed female

nice fucking memory leak.

just make an array of *char silly

Vector of strings.
>segmentation fault
Either you didn't set the vector's size or, more likely, string size.

No a string array is a char ** and these people are all fucking retarded for giving such shit answers a d talking down while doing it

>how do I implement an ARRAY

you might be retarded OP