using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace FriendBirthdayReminder
{
class Program
{
static void Main(string[] args)
{
FileStream file = new FileStream("FriendsData.txt", FileMode.Open, FileAccess.Read);
StreamReader reader = new StreamReader(file);
const char DEMLIM = ',';
const int END = 999;
int count = 0,num,size;
string name,recordIn;
string[] fields;
name = reader.ReadLine();
fields = name.Split(DEMLIM);
while (name != null)
{
++count;
name = reader.ReadLine();
recordIn = reader.ReadLine();
}
size = (int)file.Length / count;
Console.Write("\nEnter a Month ");
num = Convert.ToInt32(Console.ReadLine());
while (num != END)
{
Console.WriteLine("People born in this month: ");
file.Seek((size - 1) * size, SeekOrigin.Begin);
name = fields[0] + " " + fields[1];
Console.WriteLine(" " + name);
while (name != null)
{
name = reader.ReadLine();
Console.WriteLine(" " + name);
}
Console.Write("\nEnter a Month(Enter " + END + " to quit) ");
num = Convert.ToInt32(Console.ReadLine());
}
reader.Close();
file.Close();
}
}
}
when the user enters in s birthday month(number format) the program will display everyone who is born in the same month.
ex of the file
John,Doe,757-845-8658,12,26
first name, last name, phone number, birthday month, birthday day
can someone help me fix this?