In some case string are good in other they arent same for char
/**Exemple 1 string use in this case string is cut by Spaces at the output if we wrote del test.txt the the output will be Line 1 del Line 2 test.txt wich is not good **/
#include <iostream>
#include <stdlib.h>
using namespace std ;
string get_input ;
int main()
{
main:
cin >> get_input ;
system(get_input.c_str()) ;
goto main ;
}
/** Exemple 2 same program but we pass the input in a char with a field of 80 the output for the same cmd as first exemple will be del test.txt on the same line wich good**/
#include <iostream>
#include <stdlib.h>
using namespace std ;
char input[80] ;
string get_input ;
int main()
{
main:
cin.getline(input ,80) ;
get_input = input ;
system(get_input.c_str()) ;
goto main ;
}
Strings are objects that represent sequences of characters.
The standard string class provides support for such objects with an interface similar to that of a standard container of bytes, but adding features specifically designed to operate with strings of single-byte characters.
The string class is an instantiation of the basic_string class template that uses char (i.e., bytes) as its character type, with its default char_traits and allocator types (see basic_string for more info on the template).
Note that this class handles bytes independently of the encoding used: If used to handle sequences of multi-byte or variable-length characters (such as UTF-8), all members of this class (such as length or size), as well as its iterators, will still operate in terms of bytes (not actual encoded characters). -C++ Reference http://www.cplusplus.com/reference/string/string/
[1]:
i suggest to look at: