What do .c and .h file extensions mean to C?

前端 未结 6 1582
有刺的猬
有刺的猬 2020-12-04 08:29

It\'s all in the title; super-simple I reckon, but it\'s so hard to search for syntactical things anywhere.

These are two library files that I\'m copying from CS50.n

6条回答
  •  Happy的楠姐
    2020-12-04 08:49

    The .c files are source files which will be compiled. The .h files are used to expose the API of a program to either other part of that program or other program is you are creating a library.

    For example, the program PizzaDelivery could have 1 .c file with the main program, and 1 .c file with utility functions. Now, for the main part of the program to be able to use the utility functions, you need to expose the API, via function prototype, into a .h file, this .h file being included by the main .c file.

提交回复
热议问题