Click here to Skip to main content
13,252,183 members (56,091 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 '$'
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 6:16am
Sergey Alexandrovich Kryukov 12-Dec-12 11:31am
What problems, for goodness sake? :-)
Mohibur Rashid 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
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.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171114.1 | Last Updated 12 Dec 2012
Copyright © CodeProject, 1999-2017
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