How can I print the other elements in the array using pointers? I can do it with the first element of the array which the pointer is pointing to but I am confused in doing it with two dimensional arrays.
#include <stdio.h>
#include <stdlib.h>
void getInfo(char* pID, int* pHP);
void dispInfo(char* pID, int* pHP);
int main()
{
//declarations
char ID[100][15] = {""}; //char* pID[100];
char* pID = &ID[0][0];
int HP[100] = {0};
int* pHP = &HP[0];
int answer = 0;
int Ecount = 0;//keep count of engines input/processed
//input
do {
getInfo(pID + Ecount, pHP + Ecount);
Ecount++;
printf("More? 1 for yes 0 for no: ");
scanf("%d", &answer);
}while(answer != 0);
//output
dispInfo(pID, pHP);
return 0;
}
void getInfo(char* pID, int* pHP)
{
printf("Enter engine ID: ");
scanf("%s", pID);
printf("Enter engine HP: ");
scanf("%d", pHP);
}//end getInfo
void dispInfo(char* pID, int* pHP)
{
printf("Engine ID: %s\n", pID);
printf("Engine HP: %d\n", *pHP);
}//end dispInfo