This question already has an answer here:
- Should I reuse variables? 10 answers
Say I have a variable name
len in a function and several strings. Can I use this to store length of those strings one after the other or should I create separate variables?
size_t len; len = string1.size() ....//some code len = string2.size() ...//more code
size_t str1len, str2len; str1len = string1.size() ....//some code str2len = string2.size() ...//more code
All are local variables within a function BTW.