7 Replies - 653 Views - Last Post: 23 August 2009 - 02:10 AM Rate Topic: -----

#1 as88  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 21-August 09

How do i output appointments for today

Posted 22 August 2009 - 12:11 PM

Hello.....

I need to create a code in c++ that takes the appointments stored in a txt file and only list the appointments for today. Could anyone tell me how do i go about this? If i should use time.h ....how do i write the code?

PS: The appointments are stored in the txt file int his manner.
1. 12 february 2009
2. 13 march 2009

and so on....

THank You..
Is This A Good Question/Topic? 0
  • +

Replies To: How do i output appointments for today

#2 bgonzales999  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 108
  • Joined: 07-February 09

Re: How do i output appointments for today

Posted 22 August 2009 - 03:52 PM

getline maybe. Go write some code and then come back and ask a more specific question.
Was This Post Helpful? 0
  • +
  • -

#3 Ancient Dragon  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 81
  • View blog
  • Posts: 679
  • Joined: 19-July 09

Re: How do i output appointments for today

Posted 22 August 2009 - 05:35 PM

First, create a string that contains today's date. You will probably want to use some of the functions in time.h, such as time() to get current date and time, then strftime() to format the date string. Look those functions up online to find out how to use them.

After that, open the file and loop through it using getline(). For each line read it needs to compare the date on the line with the current date created above.

This post has been edited by Ancient Dragon: 22 August 2009 - 05:36 PM

Was This Post Helpful? 0
  • +
  • -

#4 as88  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 21-August 09

Re: How do i output appointments for today

Posted 22 August 2009 - 09:57 PM

View PostAncient Dragon, on 22 Aug, 2009 - 04:35 PM, said:

First, create a string that contains today's date. You will probably want to use some of the functions in time.h, such as time() to get current date and time, then strftime() to format the date string. Look those functions up online to find out how to use them.

After that, open the file and loop through it using getline(). For each line read it needs to compare the date on the line with the current date created above.


Thank you......ill give it a try
Was This Post Helpful? 0
  • +
  • -

#5 as88  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 21-August 09

Re: How do i output appointments for today

Posted 22 August 2009 - 11:31 PM

View Postas88, on 22 Aug, 2009 - 08:57 PM, said:

View PostAncient Dragon, on 22 Aug, 2009 - 04:35 PM, said:

First, create a string that contains today's date. You will probably want to use some of the functions in time.h, such as time() to get current date and time, then strftime() to format the date string. Look those functions up online to find out how to use them.

After that, open the file and loop through it using getline(). For each line read it needs to compare the date on the line with the current date created above.


Thank you......ill give it a try


Hey, I have been trying to get the time and convert it to string but i dnt seem to get it rite....need helppp.....pls..
Was This Post Helpful? 0
  • +
  • -

#6 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: How do i output appointments for today

Posted 23 August 2009 - 01:55 AM

Show us the code you have written so far and an extract (say 5 lines) of the text file you are working against.
Was This Post Helpful? 0
  • +
  • -

#7 as88  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 40
  • Joined: 21-August 09

Re: How do i output appointments for today

Posted 23 August 2009 - 02:00 AM

View Postjanotte, on 23 Aug, 2009 - 12:55 AM, said:

Show us the code you have written so far and an extract (say 5 lines) of the text file you are working against.


#include<iostream>
#include<ctime>





string date()

{

 

SYSTEMTIME time;

 

GetLocalTime( &time );

int hour = time.wHour;

 

if (hour > 12) hour -= 12;

 

cout << time.wMonth << "/" << time.wDay << "/" << time.wYear << endl;

cout << hour << ":" << time.wMinute << endl;

 

int a = time.wDay;

 

// attempt to put date into a string

std::string date=time.wDay+"/"+time.wMonth+"/"+time.wYear;


 

//attempt to just return the values but wont work, should this function be int or something else??

return date;



this is what is in the txt file..
12 February 2009 assignment one
13 march 2009 test one
13 august 2009 test two
15 december 2009 assignment two

Please assist me....thank you...:)
Was This Post Helpful? 0
  • +
  • -

#8 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: How do i output appointments for today

Posted 23 August 2009 - 02:10 AM

That code doesn't do anything like what your said you are trying to do (other than it is vaguely date related).

Did you post the wrong code?

If this is all you have so far then you will need to do some work of your own before others can help you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1