AIXSPadmin
MIS
Regarding pointers, what does the representation mean with two asterisks, such as:
char **s
char **s
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define arbitrary 17
char **stringArrCreate(int);
int main(void) {
int i = 0;
char *stringpt[] = {"one","two","three"};
char **pointstring = stringpt;
time_t mytime;
time(&mytime);
srand(mytime);
while (i < 3) {
printf("Original: %s\n", pointstring[i]);
printf("Random array...\n");
pointstring = stringArrCreate(3);
printf("Random: %s\n", pointstring[i]);
pointstring = stringpt;
i++;
}
return 0;
}
char **stringArrCreate(int num) {
int i, p;
char **retArr = malloc(num * sizeof(char *));
for (i=0 ; i < num ; i++) {
retArr[i] = malloc(arbitrary * sizeof(char));
p=0;
while (p < (arbitrary - 1)) {retArr[i][p] = (char)(1 + rand() % 255); p++;};
retArr[i][p+1] = '\0';
}
return retArr;
}