Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. how to search through an external file

how to search through an external file

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestiondata-structures
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    foxele
    wrote on last edited by
    #1

    I have an external file in notepad(.txt) and I have many lines of records in it: example: my name is jim I have a car it is a beautiful day . . . If I want to store the next four lines start from "my name is jim" to an array of string class, how can I do it? I was trying to use strcmp to find line, but after I locate the line, I can only store one line into a string class. How can I store the following three lines into the string classes?

    C 1 Reply Last reply
    0
    • F foxele

      I have an external file in notepad(.txt) and I have many lines of records in it: example: my name is jim I have a car it is a beautiful day . . . If I want to store the next four lines start from "my name is jim" to an array of string class, how can I do it? I was trying to use strcmp to find line, but after I locate the line, I can only store one line into a string class. How can I store the following three lines into the string classes?

      C Offline
      C Offline
      Curi0us_George
      wrote on last edited by
      #2

      Either store each following line in its own string (i.e. have 3 different string objects), or concatenate the strings. e.g. std::string str = "my name is jim"; str += "\n" + getLineFromInputFile(); //...

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups