C Program

Hello. I have a qustion about a C program and I don't know any other Forum. Suposly I asked the user of the program to enter an id card number, height, weight and gender, then i calculated the BMI with that info and then i create a file .txt and I put all that data on the file for multiple people. With that said, my problem is, now I need to ask the user a id number of someone and if that person is in the file .txt delete that person, if not should apppear a message saying the id card number doesnt exist in the file .txt

I would say that C is not the right language for such a task. Is this an assignment?

If you use a language like JavaScript, the easiest way is to save your serialized data structure as a JSON file, that is arranged as

{
012345: {
    height: 1.80,
    weight: 80,
    BMI: ???
},
012346: {
    ...
}
}

In Python, use a dict and serialize it using pickle.

Pieter

BMi can be calculated as: weight / (height * height)

Yes, it's an assignment. It has to bem in C Language

The easy, non-portable, bad way: create an array of structs, and write it to a binary file. Use the first byte as a size indication, then read it back into the array when you run the program. Then just use linear search to find the ID you want.

The right way: define a file format for your file format (something in between of CSV and JSON, probably), and write a parser.

If this is an assignment, you probably should have some idea what kind of topics were mentioned in the course, so you'll have an idea of what they expect you to do.