Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "hard coded" mean?

My assignment asks me to access a test.txt document, so the file name has to be hard coded to my C drive. I have no idea what hardcoding means. Can somebody please help me with this?

like image 901
LilProblems Avatar asked Dec 13 '09 06:12

LilProblems


People also ask

What is hard-coding example?

(1) A part of a program that has been declared as unchanging. For example, a constant is hard coded and remains the same throughout the execution of the program. (2) Programming code that solves a problem but offers less flexibility for future changes.

What does hard coded mean in healthcare?

Hard coding is when codes are assigned by the CDM without human intervention, whereas soft coding is when codes are manually assigned by a coding specialist.

What does hard coded values mean?

Hard coded test values are scalar values or value objects that are used directly in fixture setup, as parameters in the test exercise or as expected values in the verification. That is, they are not assigned to a named constant or variable.

What is considered hard-coding?

A hardcode is a part of a computer program which cannot be altered in any way except by changing the source code of the program itself. This means that if the software has already been compiled and made into an executable, the hardcoded portion of the program stays constant no matter what is done to the software.


1 Answers

"hard coding" means putting something into your source code. If you are not hard coding, then you do something like prompting the user for the data, or allow the user to put the data on the command line, or something like that.

So, to hard code the location of the file as being on the C: drive, you would just put the pathname of the file all together in your source code.

Here is an example.

int main() {     const char *filename = "C:\\myfile.txt";      printf("Filename is: %s\n", filename); } 

The file name is "hard coded" as: C:\myfile.txt

The reason the backslash is doubled is because backslashes are special in C strings.

like image 65
steveha Avatar answered Oct 18 '22 17:10

steveha