Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <getopt.h>
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct fileInfo {
- char accessRights[12];
- short hardLinks;
- short userName;
- short groupName;
- long size;
- char *time;
- char *fileName;
- short nrOfNode;
- } fileInfo;
- void enlargeFileInfos(fileInfo **fileInfoArray, int currentSize)
- {
- fileInfo *temp = (fileInfo*)realloc(fileInfoArray, (currentSize + 1) * sizeof(fileInfo));
- if (!temp) {
- printf("realloc --FAILED--\n");
- return;
- }
- *fileInfoArray = temp;
- printf("fileInfo grew to %d item(s)\n", currentSize + 1);
- }
- int main( )
- {
- size_t nrOfDirs = 1;
- fileInfo *fileInfoArr = malloc(sizeof(fileInfo));
- for (int i = 0; i < 5; i++) {
- enlargeFileInfos(&fileInfoArr, nrOfDirs);
- nrOfDirs++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement