Posts

Access violation with C++ -

i bit rusty c languages, , have been asked write quick little application take string stdin , replace every instance of letter 'a' letter 'c'. feel logic spot on (largely reading posts on site, might add), keep getting access violation errors. here code: #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> using namespace std; int main() { printf("enter string:\n"); string txt; scanf("%s", &txt); txt.replace(txt.begin(), txt.end(), 'a', 'c'); txt.replace(txt.begin(), txt.end(), 'a', 'c'); printf("%s", txt); return 0; } i can use insight. thank much! scanf doesn't know std::string is. c++ code should this: #include <string> #include <iostream> #include <algorithm> using namespace std; int main() { cout << "enter string:" << endl; string txt; cin ...

routing - Rails router: Avoiding long helpers -

consider following snippet router.rb resource :user namespace :settings resource :access_filter end 'settings' end this generates url's want ( user/settings/access_filter ), produces undesired directory structure , long url helpers. in case, helper becomes new_user_settings_access_filter , prefer have new_access_filter . , rails expects accessfilterscontroller reside in module named settings . i way keep flat directory structure, flat url helper structure, "nested" url structure. long no parameters neccessary, don't think controllers , views needs know access filters nested under user model , retain opportunity move them options/access_filter without breaking site. sugggestions on how there appreciated. if want prefix path, avoid nesting , hassle involved using separate scope . organizationally, seems make sense well, since want decouple access filter routes user. scope "user/settings" resource :access_fil...

javascript - how to build a visual representation of a wall and tiles with java script? -

so i've been set task interview i'm struggling finish it. task : build html page can input dimensions (height , width) of set of tiles , input dimensions (height , width) of wall. the page return number of tiles needed fill wall, give visual representation of wall tiles on it. so far i've managed easy math work out tiles have no clue start show wall. <form > tile dimensions<br /> width: <input type="text" id="tile_width" />cm height: <input type="text" id="tile_height" />cm <br /> wall dimensions<br /> width: <input type="text" id="wall_width" />cm height:<input type="text" id="wall_height" />cm </form> <button onclick="tilecalc()" >calculate</button> <script language="javascript" type="text/javascript"> function tilecalc() { var tilewidth = document.get...

java - Scanner only reading 1st token of a string -

new java language, the following bit of code. whole string isn't written file. first token written file. explanations ? import java.io.filewriter; import java.io.ioexception; import java.util.scanner; public class fichiertextewrite { /** * @param args */ public static void main(string[] args) { // todo auto-generated method stub try { system.out.println("entrez le nom d'un fichier :"); scanner in = new scanner(system.in); string filename = in.next(); filewriter fwrite = new filewriter(filename); system.out.println("entrez une phrase memoriser"); fwrite.write(in.next()); system.out.println("writing on file complete "); fwrite.close(); }catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } } } i have tried nextline() method didn't se...

joomla wrong base href results in wrong CSS template -

i have installed joomla 3.x , modules. one of modules display articles categories of articles, when navigate article , css stylesheets not load. when view source, discovered url css stylesheet in page above becomes: <base href="http://cambridge.mywebcommunity.org/index.php/10-%e7%88%b1%e7%ab%8b%e6%96%b9%e5%8a%a8%e5%90%91%e6%9b%b4%e6%96%b0/3-welcome-to-your-blog" /> ... instead of original put in, here: <base href="http://cambridge.mywebcommunity.org/" /> this happens css stylesheet module. css url loads this: <link rel="stylesheet" href="http://cambridge.mywebcommunity.org/10-爱立方动向更新/modules/mod_news_pro_gk5/interface/css/style.css" type="text/css" /> ... instead of original css url put in: <link rel="stylesheet" href="http://cambridge.mywebcommunity.org/modules/mod_news_pro_gk5/interface/css/style.css" type="text/css" /> so have figured out issue urls no...

jquery - How to launch existing HTML content in a Bootstrap Modal dynamically, without having modal html for each link? -

i've read few articles on loading remote content modals or dynamic content, , have read #531 issue https://github.com/twitter/bootstrap/issues/531 can't quite find want, perhaps because i'm thinking problem in wrong way. i have list of content, each item showing different product , details it. want able click 'view details' link each product, , have same content populate in modal, use css display small additional information (my question how retrieve different content dynamically, think given how little data need, it's not worth request). the html list item: <ul> <li class="span4 product"> <div class="inner"> <img src="xxxxx" alt="product xxxxx" /> <div class="control-group"> <label class="control-label">product type:</label> <span class="field">really cool product...

io - How performance of reads/writes to regular file varies when linux kernel memory load becomes high? -

it seems writes/reads regular files can't not made non-blocking. found following references support: from linux programming interface: linux , unix system programming handbook: "--- nonblocking mode can used devices (e.g., terminals , pseudoterminals), pipes, fifos, , sockets. (because file descriptors pipes , sockets not obtained using open(), must enable flag using fcntl() f_setfl operation described in section 5.3.) o_nonblock ignored regular files, because kernel buffer cache ensures i/o on regular files not block, described in section 13.1. however, o_nonblock have effect regular files when mandatory file locking employed (section 55.4). ---" from advanced programming in unix environment 2nd ed: "--- said system calls related disk i/o not considered slow, though read or write of disk file can block caller temporarily. ---" from http://www.remlab.net/op/nonblock.shtml : "--- regular files readable , writeable. stated in releva...