Char query 02-16-2014, 02:35 PM
#1
I have this function,
Now If the function is like:
I can't compile, I get a debug error, When I use std:
tring instead of char, to be precise! Why is that so? Why I have to use char, can't I use string to achieve this? Can any one shed some light on that..
Code:
void load_dict(char filename[15]) {
std::ifstream dict; //Load Dictionary
dict.open(filename);
char test[25]; //Character Limit
for(int i = 0; i < count_file(filename); i++) {
dict >> test;
std::cout << test;
}
}Now If the function is like:
Code:
void load_dict(std::string filename) {
std::ifstream dict; //Load Dictionary
dict.open(filename);
char test[25]; //Character Limit
for(int i = 0; i < count_file(filename); i++) {
dict >> test;
std::cout << test;
}
}I can't compile, I get a debug error, When I use std:
tring instead of char, to be precise! Why is that so? Why I have to use char, can't I use string to achieve this? Can any one shed some light on that..




![[+]](https://sinister.li/images/modern/collapse_collapsed.png)
![[Image: wvBFmA5.png]](http://i.imgur.com/wvBFmA5.png)