I'm pretty new to C and I'm trying to figure out how to access a specific character in a specific string in an array of strings. For example, I've got an array of strings, rec[2], which contains four strings. They can be anything but let's say:
rec[0] = test1
rec[1] = test2
rec[2] = test3
I'd like to be able to reference the fifth character in each of the strings in the array. Here's what I've got, but it's not working. Note that the "rec" array has been passed into this function and I'm able to reference whole strings, but not specific characters.
I thought that something like rec[0][4] would give me the fifth character of the first string, but it's not. I get a "segmentation fault" which I believe is indicating that rec[0][4] doesn't exist. Any help would be greatly appreciated.Code:int i; for(i = 0; i < 3; i++) { printf("%s is test number %d\n", rec[i][4], i+1); }