Message from @Perihelion - CA

Discord ID: 407686920576040974


2018-01-29 23:31:56 UTC  

@everyone
```c
char c[] = "Str";
c[1] = 'r';
printf("%s\n", c); //Output: Srr
```
How to get this to work with an array of strings? I have an array of strings (char*) and I need to modify individual characters of each string. I'm getting segfaulted because I had type `char**`. Now I know `char[]` works for individual strings but how can I extend that to arrays of them? I'm writing this in C btw.

2018-01-29 23:33:07 UTC  

@JesseJames what do you think?

2018-01-29 23:34:50 UTC  

@John O - obviously I know the answer but I think the outcome would be satisfying.

2018-01-29 23:35:06 UTC  

Ball peen or claw?

2018-01-29 23:41:31 UTC  

Hmm that's a tough one.

2018-01-29 23:46:17 UTC  

You not happy with StackOverflow answer, @sigruna14 ?

2018-01-29 23:46:50 UTC  

1st answer here is easier than me writing out pointer thingy data structure: https://stackoverflow.com/questions/1088622/how-do-i-create-an-array-of-strings-in-c

2018-01-29 23:50:29 UTC  

@Why Tea I'm not sure how that addresses what I'm trying to do here.

2018-01-29 23:51:25 UTC  

Then maybe I don't understand the question. "How do I create an array of strings" is your question, and the second answer in that StackOverflow pretty much covers it.

2018-01-29 23:51:45 UTC  

For multiple cases.

2018-01-29 23:51:52 UTC  

No, I know how to create an array of strings. My question is how to modify individual characters of the strings within said array.

2018-01-29 23:53:40 UTC  

The answer to that is in there if you read carefully.

2018-01-29 23:55:07 UTC  

```c
char a[2][14];
strcpy(a[0], "blah");
strcpy(a[1], "hmm");```

2018-01-29 23:55:18 UTC  

You're talking about this? Wholesale string copy?

2018-01-29 23:56:55 UTC  

Are you wanting to hit the individual characters in the string and substitute? I think I did miss the gist of what the question is. You have variable length strings, in an array structure (pointers to a bunch of strings) but you want to change just individual characters at will?

2018-01-29 23:59:48 UTC  

It is an array of three strings, each of which is three characters long. It starts out with each string being `"000"`. I need to be able to reach in and change the zeroes to ones where necessary.

2018-01-30 00:00:36 UTC  

Aha.

2018-01-30 00:01:01 UTC  

But you want to reach in and "touch" each one individually, at will.

2018-01-30 00:01:20 UTC  

Pointer math

2018-01-30 00:01:23 UTC  

Yes.

2018-01-30 00:02:16 UTC  

Add data type size to array pointer to access each char

2018-01-30 00:03:03 UTC  

Assuming your language won't let you index the array like a normal person

2018-01-30 00:04:13 UTC  

That's all indexes are anyway. Array pointer + index * data type size

2018-01-30 00:04:19 UTC  

Well I mean, obviously it won't.

2018-01-30 00:04:42 UTC  

So do like `*array + (sizeof(char) * 2)`?

2018-01-30 00:04:49 UTC  

Yes

2018-01-30 00:13:59 UTC  

@Perihelion - CA Nope, "lvalue required as left operand of assignment"

2018-01-30 15:36:18 UTC  

I think you have to use &array to let it know you're treating the array like a bit literal

2018-01-30 15:44:29 UTC  

Ok do this for c++ *(array+2) to get value

2018-01-30 15:44:58 UTC  

Array + 2 for mem address reference

2018-02-01 18:08:59 UTC  

I'm having a weird problem. Anybody wanna help?

2018-02-01 19:45:47 UTC  
2018-02-02 16:10:48 UTC  

@sigruna14 is it a C thing?

2018-02-02 16:11:25 UTC  

Yeah but it works now. Actually you want the code? See if you can break it. I think it's working. Still need to document it but I can tell you what it accepts.

2018-02-02 16:11:57 UTC  
2018-02-02 16:13:47 UTC  

Yeah let's do it man @sigruna14

2018-02-02 16:14:18 UTC  

Okay, I'll DM it to you. But first I'm gonna try to change how I find the command line args to be a little less ridiculous.

2018-02-02 17:04:50 UTC  

Ok!

2018-02-04 16:51:39 UTC  

Hey does anybody know how to put music behind a video I’m editing… I’m using iMovie app

2018-02-04 17:32:38 UTC  

@Deleted User you just have to have an audio file on your phone. Select the plus on the left side and then select audio.

2018-02-04 20:00:54 UTC  

@JesseJames many times it won’t allow me to upload the song..”copyright” infringement is what the message says... I just (like five mins ago) bought a GoPro .... will that be easier to operate ya think ?