Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
i want to compare a (user entered) string with a string present in a file. how i can compare both strings.
Every line of my file consists of two things; course code and course Name ending with delimeter '$'
e.g
cs103$ computer programming $
 
If user enters cs103 our program should save course name respective to that course code in an array .And then save that course name in a file
 
I am having problems in comparing . .. . both strings
Posted 12-Dec-12 5:16am
Comments
Sergey Alexandrovich Kryukov at 12-Dec-12 11:31am
   
What problems, for goodness sake? :-)
--SA
Mohibur Rashid at 12-Dec-12 19:33pm
   
why $ sign whats wrong with new line? I already seen your another question. the file actually contains new line.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You need to read your file first and build an array, or better still a std::map[^] of the contents. As you read the file you need to split the strings into code and description, using the $ signs as delimiters, and building you map from the two strings. Then it is just a simple matter of using the input from the user to look up the title in the map.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web01 | 2.8.141015.1 | Last Updated 12 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100