user1928374
user1928374

Reputation: 71

using fseek() to find position entered by user

I need to ask the user for an ID Number, and then use the function fseek() to find the position of the ID Number entered by the user, and then be able to modify the records. I have something like this:

printf("Enter ID Card Number: \n");
scanf("%s", editCust.idNumber);
fseek(custFile, (editCust.idNumber -1)*sizeof(struct customer), SEEK_SET);

Upvotes: 1

Views: 1114

Answers (1)

coelhudo
coelhudo

Reputation: 5080

No.

First, substitute:

scanf("%s", editCust.idNumber);

for

scanf("%d", &editCust.idNumber);

%s is for string values and %d is for decimal values.

A good source of formats can be found here.

Upvotes: 2

Related Questions