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>
int main(int nArgCount, char * cpArgv[])
{
char *** cpNameBuffer = NULL;
cpNameBuffer = (char ***)calloc(10, sizeof(char **));
if (cpNameBuffer == NULL) { return 0; } //you can report error if you want to
for (unsigned short unName = 0; unName < 10; unName++)
{
cpNameBuffer[unName] = (char **)calloc(2, sizeof(char *));
if (cpNameBuffer[unName] == NULL) { return 0; } //report error if you want to
printf("Student #%i (First): ", unName + 1);
cpNameBuffer[unName][0] = GetName(); //get first name
printf("Student #%i (Last): ", unName + 1);
cpNameBuffer[unName][0] = GetName(); //get last name
}
//now you have your array of names, use it here for whatever operations you want
return 1;
}
char * GetName(void)
{
char * cpBuffer = NULL;
char * cpCPtr = NULL;
cpBuffer = (char *)malloc(256); //allocate 256 chars for temporary buffer
if (cpBuffer == NULL) { return NULL; } //you can report error if you want to
memset(cpBuffer, 0, 256); //set all to null
if (gets(cpBuffer) == NULL) { return NULL; } //you can report an error here
//sorry but gets() doesnt have a limit string size, but 256 chars chould be enough
cpCPtr = strchr(cpBuffer, '\n'); //string is \n terminated, find the \n
cpCPtr[0] = '\0' //and null terminate it
cpCPtr = NULL;
cpCPtr = (char *)malloc(strlen(cpBuffer) + 1); //alloc final char array
if (cpCPtr == NULL) { return NULL; } //you can report error if you want to
strcpy(cpCPtr, cpBuffer);
return (cpCPtr);
}