Posts

Showing posts with the label file

Save linebreaks in textarea to tpl file with php

Save linebreaks in textarea to tpl file with php I want to edit html code in a textarea and then save it to a tpl-file. When opening the template file with my desktop editor the linebreaks should just look like in the textarea, so no n or br-tag (if not actually wanted for the code) in it. Thanks for any help! Ah, changing from tpl to txt when googeling did the trick. $code = str_replace('n', PHP_EOL, $code); – user2822542 Jul 1 at 10:51 What do you mean by "changing from tpl to txt"? – Nico Haase Jul 1 at 11:05 By clicking "Post Your Answer", you acknowledge that you have re...

c++ bad_alloc error with file storage

c++ bad_alloc error with file storage So, my exercise is to read three files and write them in a new one. My first thoughts were to put the files in a vector and then write the vector in the new file. int main(int argc, char* argv){ vector<string> book; ifstream input1; input1.open(argv[1]); string line; while(!input1.eof()) { getline(input1, line); book.push_back(line); } ofstream output; output.open(argv[4]); unsigned int n = book.size(); for(unsigned int i = 0; i < n; i++) { output << book[i]; } This is a part of it. I read similar questions and they all were about items. How will i fix this problem with file rows of strings? Checking argc might be an idea if (argc < 5) return -1; – Surt Jun 30 at 15:58 By clicking "Post Your Answer...