#include <stdio.h>
#include string.h
int concat(char str[], char *lngstring[], int x);
void printreverse(char lngstring[], int x);
#define MAX_CHARS 100
int main( int argc, char *argv[] ) {
longstring[MAX_CHARS] = {'\0'};
concat(*argv[], *longstring[],argc);
printf("%s", longstring);
printreverse(*longstring[],argc);
}
int concat(char *str[], char *lngstring[], int x){
int count = 0;
int count2 = 0;
while(count <= (2 * x){
lngstring[count] = str[count2];
count += 1;
lngstring[count] = " ";
count += 1;
count2 += 1;
}
return 0;
}
void printreverse(char *lngstring[], int x){
char *cas[] = lngstring;
int count = 0;
int count2 = x;
char temp[];
char temp2[];
while(count <= x){
for(i = 0; i < x; i++){
char temp[] = cas[count];
char temp2[] = cas[count2];
cas[count2] = temp;
cas[count] = temp2;
count++;
count2--;
}
//reverse the order of strings in array
count = 0;
while(count <= x){
int bs = strlen(cas[count]);
int zx = bs;
char temp[] = cas[count]
for(i = 0; i <= bs; i++){
char temps = temp[i]
char temps2 = temp[zx]
temp[i] = temps2;
temp[zx] = temps;
zx--;
}
//reverse each individual string
cas[count] = temp;
}
printf("%s",cas)
}
This program needs to take command line arguments, concatenate them into a string array, print every element of that array, and print every element of that array in reverse. I really have no idea what I'm doing and this is my best attempt at it. I'm having a hard time grasping pointers and when and how to use them. Any help would be greatly appreciated.