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. Silly MFC CString Question

Silly MFC CString Question

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionc++json
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.
  • C Offline
    C Offline
    carrie
    wrote on last edited by
    #1

    Hi, I'm still a bit new to MFC and I'm having a really silly problem with it. I'm trying to make a dialog based program that will allow someone to pick a text file, the program loads it up and then there will be a list of things. No probs on getting to pick the txt file but what I need is for the program to be able to notice duplicate entries in the txt file and then pick one of them out, ignoring the rest of the duplicates. Also, even sillier, I need to make something that displays a bunch of strings that contain text in them. I'm having the problem though that some of the strings that I need it to show contain things like ReplyHello=/ :-: \ ReplyHelp=Help? whenever I try to do a CString m_something=(_T("ReplyHello=/ :-: \\nReplyHelp=Help?")); I get errors about teh escape codes. Any help for a lost soul? Thanks

    C 1 Reply Last reply
    0
    • C carrie

      Hi, I'm still a bit new to MFC and I'm having a really silly problem with it. I'm trying to make a dialog based program that will allow someone to pick a text file, the program loads it up and then there will be a list of things. No probs on getting to pick the txt file but what I need is for the program to be able to notice duplicate entries in the txt file and then pick one of them out, ignoring the rest of the duplicates. Also, even sillier, I need to make something that displays a bunch of strings that contain text in them. I'm having the problem though that some of the strings that I need it to show contain things like ReplyHello=/ :-: \ ReplyHelp=Help? whenever I try to do a CString m_something=(_T("ReplyHello=/ :-: \\nReplyHelp=Help?")); I get errors about teh escape codes. Any help for a lost soul? Thanks

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      carrie wrote: I'm trying to make a dialog based program that will allow someone to pick a text file, the program loads it up and then there will be a list of things. No probs on getting to pick the txt file but what I need is for the program to be able to notice duplicate entries in the txt file and then pick one of them out, ignoring the rest of the duplicates. Easy - let STL do the dirty work for you. If you store the information in an STL set, it will discard duplicates as you go. I've written an article on this, just search for 'graus map set' to find it. You can also read a text file into an STL container in just three lines of code - I show that in my STL articles as well. I don't see anything wrong with the string you're setting, but if you're getting an escape code erro,r chances are you tried to insert a \, and forgot to put two of them, as \\ is the code for \, as \ denotes the begining of an escape code, such as \n for newline, or \r for return. Don't feel silly, you should see some of the stuff I asked when I was starting. We all start somewhere. Christian The tragedy of cyberspace - that so much can travel so far, and yet mean so little. And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002

      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