我编写了一个程序,在相应的分隔符出现时拆分字符串.但是发生了一个不同的错误:
Run Code Online (Sandbox Code Playgroud)Error 1 error LNK2019: unresolved external symbol __imp___CrtDbgReportW referenced in function "public: char const & __thiscall std::_String_const_iterator<class std::_String_val<struct std::_Simple_types<char> > >::operator*(void)const " (??D?$_String_const_iterator@V?$_String_val@U?$_Simple_types@D@std@@@std@@@std@@QBEABDXZ) Source.cpp Using Object_Type Input
我在开发c ++中测试了相同的程序,它工作正常,但在visual studio中,这些类型的问题正在提升.
我的计划:
#include <string>
#include <iostream>
#include<tchar.h>
using namespace std;
#pragma comment (lib, "ws2_32.lib")
int _tmain(int argc, _TCHAR* argv[])
{
string s = "Enter a line of text,\n next line\n as the\n delimiter: ";
string delimiter = "\n";
size_t pos = 0;
string token;
while ((pos = s.find(delimiter)) …Run Code Online (Sandbox Code Playgroud) 我是log4j的新手。我创建了一个示例Java程序,在其中实现了log4j。
下面是java程序:
package logging;
import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;
public class Logging {
/**
* @param args the command line arguments
*/
private static Logger logger = Logger.getLogger(Logging.class);
public static void main(String[] args) {
BasicConfigurator.configure();
logger.trace("This is a Trace");
logger.debug("This is a Debug");
logger.info("This is an Info");
logger.warn("This is a Warn");
logger.error("This is an Error");
logger.fatal("This is a Fatal");
}
}
Run Code Online (Sandbox Code Playgroud)
我正在控制台屏幕中获取输出。但是未生成日志文件。我还使用以下链接在Eclipse霓虹灯中配置了我的项目: 配置
我做的一切都很好。但是日志文件没有生成。当我以编程方式实现log4j时,该文件正在生成。以下是我的属性文件:
#root
log4j.logger.com.apress.logging.log4j=debug,dest
log4j.additivity.com.apress.logging.log4j=false
#define the appender
log4j.appender.dest = org.apache.log4j.DailyRollingFileAppender
#set the name …Run Code Online (Sandbox Code Playgroud) 我编写了一个简单的程序来创建一个空的 JTable。但是当我显示表格时,表格下方会出现一个额外的空白。现在我想删除表格行下方的空白。
JTable 程序:
public class Table extends JFrame {
Table()
{
int numColoumns=5;
int numRows=10 ;
String[] colHeadings = {"COLUMN1","COLUMN2","COLUMN3","COLUMN4","COLUMN5"};
DefaultTableModel model = new DefaultTableModel(numRows, numColoumns) ;
model.setColumnIdentifiers(colHeadings);
JTable table = new JTable(model);
JTableHeader head = table.getTableHeader();
Container c = getContentPane();
c.setLayout(new BorderLayout());
c.add("North", head);
c.add("Center",table);
}
public static void main(String[] args) throws NumberFormatException, IOException
{
Table t = new Table();
t.setSize(500,400);
t.setVisible(true);
t.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}}
Run Code Online (Sandbox Code Playgroud)
程序给了我一个表格,但行没有完全填满窗口。它显示了一个窗口,具有给定的高度和宽度(以像素为单位)以及相应的行数。在创建的行下方,它显示了一个额外的空间,因为这些行没有填充到窗口中。任何人都可以帮助我从窗口中删除多余的空间。
抱歉,我创建了输出图像,但上传图像时出现问题。