Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compairing character strings and ints of other

Status
Not open for further replies.

TalosBlack

Programmer
Jan 6, 2004
33
US
I am trying to compare date from a file which i infile from a text file to data from and actual file which i get through looking at it's attributes. The problems is i am checking that: A. the files names are the same, B. The file size is the same, and C. That the date modified is the same. The data that i'm in fileing is in the form of text or in other words character arrays. However the attributes that i'm getting are not of this type (well the file name is). One is of type '_fsize_t' the other 'time_t'. I'm failry sure that _fsize_t amounts to an int. I'm not so sure about the time_t. I'm not sure how i can compare these files. I pressume you need to do something like type casting the data before making the comparison but i can't seem to figure how to do that. Any suggestions would be great.

Thanks

John
 
I found the answer to this myself yesterday and i will post it encase anyone cares. strtol() can convert a string to a long integer so you can use a simple == to make a comparision. This assumes that your char array is a legimate integer. Which in the case of size it was. Buy using ctime i was able to store the time data as a char array. And then i used strnmp == 0. After some tweeking everything seemed to work fine.

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top