Category : string

int main() { // No. of Partitions of input file. int num_ways = 10; // The size of each partition int run_size = 1000; char input_file[] = "input.txt"; char output_file[] = "output.txt"; FILE* in = openFile(input_file, "w"); srand(time(NULL)); // generate input for (int i = 0; i < num_ways * run_size; i++) fprintf(in, "%d ", ..

Read more

I have fixed it another way but I still want to know why stoi is not working here. This is the code: #include <string> #include<iostream> std::string fakeBin(std::string str){ for(int i=0;i<str.size();i++){ int number=stoi(str[i]); std::cout<<number<<std::endl; } return "a"; } int main() { fakeBin("12354234"); return 0; } while compiling int number=stoi(str[I]); I get this error: ‘stoi’ was not ..

Read more

I’m a new StackOverflow user! i need help. My task is to find two verbs in the string that are in the list (_words[]) and swap them. With string it’s not that hard to implement, but I’m only allowed to use char. My idea is this: I split the char(char str[]) array into words, and ..

Read more

[https://practice.geeksforgeeks.org/problems/longest-even-length-substring/0] Hi all, I solved the above problem using a one-dimensional array. But I don’t know what is wrong with my code. It is failing. Can you please analyze my code and give me an explanation of why my approach was failing with a proper example. #include<iostream> using namespace std; int main() { int t; ..

Read more