1 Replies - 638 Views - Last Post: 20 April 2013 - 04:24 AM Rate Topic: -----

#1 gwnabaprmr  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 25
  • Joined: 08-August 08

Compare data from a txt file and an input.

Posted 20 April 2013 - 02:30 AM

Hello I have a txt file of this formation

I want to read these data and check if the IP I insert manually
matches any of these IP's. I don't want to Process MAC column whatsoever.
What should I do?
Please be specific.
I know it is something with scanf but I dont now how I will store the Column that I want.
That is the key problem that I have.
Thanks in Advance.


	//Struct data
	typedef struct 
	    char *ip;
	    char *mac;

	int main()

		//Orismos metabliton.
    		FILE *ptr_file;
    		char buf[1000];
		char ip[1000];

		//Open txt file.
    		ptr_file =fopen("arp.txt","r");
		if (!ptr_file)
        	return 1;
		//Input IP from user
		//Test of input
		//Reading txt.
    		while (fgets(buf,1000, ptr_file)!=NULL)
			//Reading check.        		
		return 0;

Is This A Good Question/Topic? 0
  • +

Replies To: Compare data from a txt file and an input.

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6246
  • View blog
  • Posts: 24,014
  • Joined: 23-August 08

Re: Compare data from a txt file and an input.

Posted 20 April 2013 - 04:24 AM

Perhaps you can use this


Each conversion specification in format begins with either the character '%' or the character sequence "%n$" (see below for the distinction) followed by:
An optional '*' assignment-suppression character: scanf() reads input as directed by the conversion specification, but discards the input. No corresponding pointer argument is required, and this specification is not included in the count of successful assignments returned by scanf().

from the man page of scanf to come up with a possible solution.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1