Help to complete this task

+2 Collin Archer · November 27, 2015
I am trying to take in a name using scanf in my code and then check if the name is correct by reading a file. I know how to just read a file on its own but I am very confused on how to complete this task. I would greatly appreciate some help.

Post a Reply

Replies

Oldest  Newest  Rating
+2 Dan P · November 27, 2015
Hi Collin,

Think about it like this....

scanf will put a string in 1 data storage, ie. char myInputString[];

Then opening a file and reading the contents you put the data in to another data storage location, ie char fileInputString[];

Then you compare the 2 strings to see if they match.

The difficult part is when you have many names in the file, or you have a file structure where the name is only 1 item of many.

For example.

File A.
-----

name1
name2
name3

File B.
-----
id=123
name=name1
address=myaddress

Then you have to read the file data in and then check through it.

I hope this helps.

Dan
  • 1

C

107,197 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator