Search Results

Search found 2 results on 1 pages for 'brundle'.

Page 1/1 | 1 

  • C++: Keep track of times function is called.

    - by Brundle
    Keeping track of how many times a function is called is easy when passing the counter as an argument into the function. It's also easy when returning a one from the called function. But, I do not want to go that route. The reason behind this is because it seems like bad programming (letting the function know too much information). Is there a better way to keep track of how many times this function has been called? I'm just looking for concepts that I could study. Providing code examples is not neccessary, but might be helpful.

    Read the article

  • C++: Checking for non-numeric input and assigning to a double

    - by Brundle
    Here is the code I have at the moment: char ch; int sum = 0; double values[10]; int i = 0; cin >> ch; while (!isalpha(ch)) { values[i] = ch; sum += values[i]; i++; cin >> ch; } What is happening is that if I enter the value 1, that gets assigned to ch as a char. Now ch is assigning it's value to a double and doing an implicit cast. So it is assigning the ASCII value of '1' to values[i]. I want it to just assign 1 to values[i]. Is there a better way to do this? Or is there something that I'm missing?

    Read the article

1