开发者

read & write from file [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarify开发者_运维知识库ing this question so that it can be reopened, visit the help center. Closed 12 years ago.

I want to write a program in c++ that prompts a user for a file name of an existing file that contains 10 records where the length of each record is 12 characters. next the program seeks to the beginning of the 6th record, reads the records in the file and append them to the end of an existing output file that contains 3 records. Thank you.


You may find this useful:

#include <iostream>
#include "McDonaldsApplication.h" 

int main()
{
  McDonaldsApplication app;
  string name, dob, pos, ssn;
  std::cout << "Enter your name: " << std::endl;
  std::cin >> name;
  std::cout << "Enter your DOB: " << std::endl;
  std::cin >> dob;
  std::cout << "Enter your SSN: "  << std::endl;
  std::cin >> ssn;
  std::cout << "Enter your desired position (0,1,2): " << std::endl;
  std::cin >> pos;
  std::cout << "Thank you! Your application is being submitted now\n";
  app.setName(name);
  app.setDob(dob);
  app.setSsn(ssn);
  app.setPos(pos);
  app.submit();
}


Since you didn't actually ask a question (questions end in a '?') I'll post a semi-related implementation of what you may have meant, in a language of my choice.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace TestConsole
{
 class Program
 {
  /// <summary>
  /// http://www.mcdonalds.com/us/en/careers.html
  /// </summary>
  /// <param name="args"></param>
  static void Main(string[] args)
  {
   using (StreamWriter writer = new StreamWriter("c:\\mcdonalds_app.txt"))
   {
    writer.WriteLine("Hello, my name is {0}. I'd love to work here!", args[0]);
    writer.Close();
   }
  }
 }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜