CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Mar 2010

    How to know if Key in Vector does not exist / If File has write permissions

    Hi all,

    I have 2 questions to ask, and I decided to ask them in a single thread (to save space for the other forum goers).

    1. How to find if a key in a vector doesnt exist?

    Ex. There is a hash_map Dictionary defined Dictionary[<string>, <string>] (meaning the key is represented as a “string”, and the value is also a string

    If I have something like this:

    hash_map <string, string> Dictionary;

    string doesNotExist = “does not exist”
    string DictValue = Dictionary[doesNotExist];

    It should identify that the Key for that Dictionary does not exist.

    It does not error however, but it returns a blank string "". I want to identify if the key does not exist since it may be possible that the key exists but also contains a blank string "".

    2. How to find if a file is writable to or not?

    The problem I have is the file can be opened if it has read permissions but it cannot be written to since it has no write permissions. I am imagining something like this:

    //write to the file
    Printf(“Error: File is not writable”);

    I tried searching but all I find is if the file exists, etc.

    Thank you all for the future help!
    Last edited by LeanA; April 27th, 2010 at 08:05 AM. Reason: Clarification in question 1

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.