如何从ifstream获取格式化输入(How to take formatted input from ifstream)
我有一个文本文件,其格式如下:
"MARY","PATRICIA","LINDA","BARBARA","ELIZABETH"
等等。 我想使用ifstream打开文件并将名称读入字符串数组(不带引号,逗号)。 我以某种方式设法通过检查输入流字符。 有一种更简单的方法来采取这种格式化的输入?
编辑:我听说你可以使用类似fscanf(f,“\”%[a-zA-Z] \“,”,str); 在C中,但是ifstream有这种方法吗?
I have a text file with a set of names formatted in the following way:
"MARY","PATRICIA","LINDA","BARBARA","ELIZABETH"
and so on. I want to open the file using ifstream and read the names into a string array (without quotes, commas). I somehow managed to do it by checking the input stream character by character. Is there an easier way to take this formatted input?
EDIT: I heard that you can use something like fscanf (f, "\"%[a-zA-Z]\",", str); in C, but is there such a method for ifstream?
原文:https://stackoverflow.com/questions/8575175
最满意答案
例如:
case 37: //atras //if the cursor is at the beginning of the field if (event.target.selectionEnd == 0) { $(atras).focus(); } break; ... case 39: //derecha //if the cursor is at the end of the field if (event.target.textLength-event.target.selectionStart == 0) { $(adelante).focus(); } break;
For example:
case 37: //atras //if the cursor is at the beginning of the field if (event.target.selectionEnd == 0) { $(atras).focus(); } break; ... case 39: //derecha //if the cursor is at the end of the field if (event.target.textLength-event.target.selectionStart == 0) { $(adelante).focus(); } break;
相关问答
更多-
得到它了。 只是发送: sendDownUpKeyEvents(KeyEvent.KEYCODE_SHIFT_LEFT); 8小时= 1行。 现在需要睡觉 got it. just had to send: sendDownUpKeyEvents(KeyEvent.KEYCODE_SHIFT_LEFT); 8 hrs = 1 line. need to sleep now
-
例如: case 37: //atras //if the cursor is at the beginning of the field if (event.target.selectionEnd == 0) { $(atras).focus(); } break; ... case 39: //derecha ...
-
这是它的代码。 您可以使用向上和向下箭头键。 这个想法是获取元素中文本的char代码,然后添加一个或从char代码中减去一个,因为字母表的字符代码如下所示:97 = a,98 = b,99 = c,... 122 = ž 对于这个例子,你必须先在文本框内单击 var letterIndex = 0; $("#scrrollLetters").keydown(function(e){ var originalString = this.value; var charCode = original ...
-
使用箭头键导航(Navigating with arrow keys)[2023-09-21]
我没有考虑任何具体的指导方针或任何东西,但似乎在第一种情况下,当你在A上并且你向右推时,它应该转到B. 如果你在推A时已经在C或D上,那么回到那个可能是有意义的。 我对这一点不太确定,因为用户可能从底部转到A作为到达B的“快捷方式”(如果右列中有很多元素,这是有道理的,所以不要去( Up-Up-Up-Up-Up-Up-Go-Left-Right)。 I haven't looked into any specific guidelines or anything, but it seems that in ... -
用箭头键浏览窗体(Navigate through form with arrow keys)[2022-03-31]
是的,一旦我获得了提示,这很容易。 这是我的解决方案: var UP = 38; var DOWN = 40; var LEFT = 37; var RIGHT = 39; var TAB = 9; $('#tab-columns').on('keydown', 'input', function (event) { var $focused = $(':focus'); var id = ($focused.parents(" ... -
如果你是e.preventDefault()也许你需要检查输入插入符号的位置以进行分析。 举个例子: http://jsbin.com/cunidinuvo/edit?html,js,output Maybe you need check position of input caret for analyse if you e.preventDefault() or not. Fallow a example: http://jsbin.com/cunidinuvo/edit?html,js,output
-
Android左右箭头键用作后退和上一个按钮(Android Left and Right Arrow Keys Act as Back and Previous Buttons)[2023-10-01]
您也可以像这样动态创建片段 // Create new fragment and transaction Fragment newFragment = new ExampleFragment(); FragmentTransaction transaction = getFragmentManager().beginTransaction(); //使用此片段替换fragment_container视图中的任何内容,//并根据需要将事务添加到后台堆栈 transaction.r ... -
我为uparrow和downarrow写了一个keydown处理程序,就像select下拉一样。 但是tab键在prevtDefault到next字段时有特定的作用,所以我不想prevtDefault浏览器行为。 请参阅下面的代码,您可以从那里构建更多代码, DEMO CSS: span.active {background:#555;color:#FFF;} JS: $(document).ready(function() { $('#myInput').focus(function() { ...
-
在所有JS文件中搜索并查找类似于以下内容的内容: keyCode == 37 要么 which == 37 因为这是左箭头。 可能某处有类似的东西: if (e.keyCode == 37) e.preventDefault(); Do a search in all your JS files and look for something similar to: keyCode == 37 or which == 37 as this is the left-arrow. Probably ...
-
添加一个document.addEventListener("keydown", function(){}) ,它将监听按键,然后确定键码并映射它们以根据键码提交表单。 提交表单就像找到表单并在其上调用.submit()一样简单! document.addEventListener("keydown", function(event) { var code; if (event.key !== undefined) { code = event.key; } else if (e ...