How do I include \"header.h\" when compiling in C ? /*--------------------------
ID: 3781391 • Letter: H
Question
How do I include "header.h" when compiling in C ?
/*-------------------------------------------------------------------------* *--- list.c ---* *--- ---* *--- This file defines struct(s) and functions for counting ---* *--- randomly-generated integers in a linked list. ---* *-------------------------------------------------------------------------*/ #include "header.h" // PURPOSE: To hold elements of a linked list that holds counts of integers. struct ListElement { int item_; int count_; struct ListElement* nextPtr_; }; // PURPOSE: To count the occurrence of 'numNums' numbers generated by // 'getNextNumber()'. Returns linked list with counts. struct ListElement* generateList (int numNums ) { struct ListElement* toReturn = NULL; struct ListElement* prev; struct ListElement* run; int i; for (i = 0; i < numNums; i++) { int nextNum = getNextNumber(); for (prev=NULL, run=toReturn; run!=NULL; prev=run, run=run->nextPtr_) if (run->item_ == nextNum) { run->count_++; break; } if (run == NULL) { struct ListElement* newItemPtr = (struct ListElement*) malloc(sizeof(struct ListElement)); newItemPtr->item_ = nextNum; newItemPtr->count_ = 1; newItemPtr->nextPtr_ = NULL; if (prev == NULL) toReturn = newItemPtr; else prev->nextPtr_ = newItemPtr; } } return(toReturn); } // PURPOSE: To print the list of counts pointed to by 'listPtr'. No return // value. void printList (struct ListElement* listPtr ) { while (listPtr != NULL) { printf("%d: %d time(s) ",listPtr->item_,listPtr->count_); listPtr = listPtr->nextPtr_; } } // PURPOSE: To free the list pointed to by 'listPtr'. No return value. void freeList (struct ListElement* listPtr ) { struct ListElement* next; while (listPtr != NULL) { next = listPtr->nextPtr_; free(listPtr); listPtr = next; } } // PURPOSE: To count the occurrence of 'numNums' numbers generated by // 'getNextNumber()' and put the counts in a linked-list. Prints this // list, and then free()s it. No return value. void countWithList (int numNums ) { struct ListElement* listPtr = generateList(numNums); printList(listPtr); freeList (listPtr); }
Explanation / Answer
If you have build you own header file headr.h then you can put it like this
#include "header.h"
"" this symbol is used for files which are user defined and then you can use it, then your program will look like this.
But I think your question is how to include compiler defined library header file which will help in execute this program. You can use stdio.h and conio.h for this program. Let me show you.
I hope your doubt is clear; if not just ask your doubt in the comment section below.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.