Sign in to follow this  
thekguy

indexing maps and strings(C++)

Recommended Posts

okay, so i have an input file of two lines which i stored in 2 strings, 1 for each line. i have to multiply the letters of the string, where a = 1...z = 26, so i have a map<char, int> with all the pairs already initialized. the strings and map are all good, i output the strings and they're right and the map works fine with regular chars... yet when i index the map with chars that i in turn indexed from the string, i always get 0. so if i have a string like ABABA i expect 1*2*1*2*1 yet i get 0*0*0*0*0 the only reason i can think for this is that it didn't recognize the key i used and instead value-initialized a new int...why?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this