我试图得到一个字符串处理程序,它从用户输入字符串类型变量...但它崩溃了,我想知道为什么?或者我做错了什么......
string UIconsole::getString(){
string input;
getline(cin,input);
if(input.empty() == false){
return input;
}
else{getString();}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
编辑:错误:
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct null not valid
Run Code Online (Sandbox Code Playgroud) 我需要初始化一个像Map x<Apartment,Vector<Expense>>它允许我,如果我@override的Map方法
Description Resource Path Location Type
The type new Map<Apartment,Vector<Expense>>(){} must implement the inherited abstract method Map<Apartment,Vector<Expense>>.isEmpty() Repository.java /proj_individual/src/repo line 12 Java Problem
The type new Map<Apartment,Vector<Expense>>(){} must implement the inherited abstract method Map<Apartment,Vector<Expense>>.size() Repository.java /proj_individual/src/repo line 12 Java Problem
The type new Map<Apartment,Vector<Expense>>(){} must implement the inherited abstract method Map<Apartment,Vector<Expense>>.keySet() Repository.java /proj_individual/src/repo line 12 Java Problem
The type new Map<Apartment,Vector<Expense>>(){} must implement the inherited abstract method Map<Apartment,Vector<Expense>>.remove(Object) Repository.java /proj_individual/src/repo line 12 Java Problem
The …Run Code Online (Sandbox Code Playgroud) 当我转换JTextField为int 时,我的GUI程序崩溃了.可以帮助我查看这段代码,看看有什么问题,因为我使用了相同的方法,并且它有效.
我所做的:
new JTextLabel l;
Run Code Online (Sandbox Code Playgroud)
在那里得到什么
String A = l.getText() >int i = Interger.parse(A);
Run Code Online (Sandbox Code Playgroud)
码:
btnAdd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int nr = Integer.parseInt(txtApt.getText());
int nrP = Integer.parseInt(txtNrPips.getText());
String owner = txtOwner.toString();
Apartment a = new Apartment(nr, nrP, owner, false);
Expense b = new Expense(Float.parseFloat(textWW.getText()), Float.parseFloat(textCW.getText()),
Float.parseFloat(textGAS.getText()), Float.parseFloat(txtELEC.getText()), Float.parseFloat(textHEAT.getText()));
ArrayList<Expense> l = new ArrayList<>();
l.add(b);
cont.addKeyWithList(a,l);
}
});
Run Code Online (Sandbox Code Playgroud)
堆:
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source) …Run Code Online (Sandbox Code Playgroud) 我试图比较两个字符串,但我没有实现这一点.为什么?
#include <stdio.h>
#include <string.h>
int main(){
float a = 1231.23123;
char b[32];
sprintf(b, "%f", a);
printf("%s\n", b);
char c[32] = "1231.23123";
if (strcmp(c, b) == 0){
printf("SUCCES\n");
}
else{
printf("DIFFER\n");
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
结果:
1231.231201
DIFFER
Run Code Online (Sandbox Code Playgroud) 可能重复:
使用整数连接两个QStrings
我期待在QT中创建一个3个整数和一个c ++ stl字符串的字符串,我该怎么做?有谁知道?,找不到解释这个过程的东西?
这是我的代码是我在lsit中创建元素,但我想打印所有元素和他们的属性不仅名称:
void Window::listMovies(){
ui->listMovies->clear();
vector <Movie> all = ctrl->getAllMovies();
for(int i=0; i <(int) all.size();i++){
QListWidgetItem*item = new QListWidgetItem(
QString::fromStdString(all[i].getName()),ui->listMovies);
item->setData(Qt::UserRole,QVariant::fromValue(all[i].getID()));
Run Code Online (Sandbox Code Playgroud)
电影对象有1个字符串和3个整数变量.
可能重复:
什么是Java?:运算符被调用,它做了什么?
您好,我在理解这些代码时遇到了一些问题,有人可以帮我解决这个问题吗?
private Comparable elementAt( BinaryNode t ) {
return t == null ? null : t.element;
}
Run Code Online (Sandbox Code Playgroud)
我不明白是什么t == null ? null : t.element;意思.
您好我为什么要*** - EVAL/APPLY: too many arguments given to F使用嵌套列表参数进行函数调用.我无法理解,因为我通过了一个简单的嵌套列表.
(defun f (L)
(cond
((NULL l) nil)
((listp (car L))
(append (F(car L))) (F(cdr L) (car (F (car L)))))
(T (list(car L)))
)
)
(setq A '((1) 2 3))
(f A)
Run Code Online (Sandbox Code Playgroud) java ×3
c++ ×2
string ×2
c ×1
clisp ×1
common-lisp ×1
comparison ×1
jtextfield ×1
lisp ×1
qstring ×1
qt ×1
swing ×1
whitespace ×1