Search the Community
Showing results for tags 'string'.
-
Is there an easy (concise, maybe one-liner) way to check if a string is 'inside' an enum? i.e. typedef enum {alpha, beta, gamma, delta, epsilon} my_enum; string my_string; my_string = <something>; //I know this is not possible, but I try to do something like this if (my_string inside {my_enum.names}) // where names would imply all of the enumeration option strings I try to avoid walking thru all of the enumerated values, which is what I currently do (and which works fine).
-
Is it possible to randomize a string without home-brewing a function to do it? Can only integral data types be randomized, hence not strings? How much memory is allocated when a string is declared? Is a string just a dynamic array 'underneath'?
-
I am trying a convert a string to a bit vector but unable to do so. Aim is to directly store the string as bit vector into Memory. Part of code: //<required libs declared> //..// string line; sc_bv<32> Mem[256]; //..// case 1: { i=1; ifstream mem_1("../mem_1.txt"); if (mem_1){ while (getline(mem_1,line)){ Mem= line; i++ ; } mem_1.close(); } else { cout << "mem_1 not found "; } break; } Where mem_1.txt contains binary: eg. 00100000000001000000000000000000 00000000010000110010100000100100 00000000011000000011000000100111 Error: /usr/local/systemc-2.3.0/include/sysc/datatypes/bit/sc_bv.h:192:15: note: sc_dt::sc_bv<W>& sc_dt::sc_bv<W>::operator=(sc_dt::int64) [with int W = 32, sc_dt::int64 = long long int] /usr/local/systemc-2.3.0/include/sysc/datatypes/bit/sc_bv.h:192:15: note: no known conversion for argument 1 from ‘std::string {aka std::basic_string<char>}’ to ‘long long int’ Thanks in advance. -- Samyak