小编Mat*_*ont的帖子

用C++连接char数组

我有以下代码,并希望最终得到一个字母,如:"你好,你好吗?" (这只是我想要实现的一个例子)

如何连接2个char数组并在中间添加","和"你?" 在末尾?

到目前为止,这连接了2个数组但不确定如何将其他字符添加到我想要的最终char变量中.

#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    char foo[] = { "hello" };
    char test[] = { "how are" };
    strncat_s(foo, test, 12);
    cout << foo;
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

编辑:

这是我在你的所有回复之后提出的.我想知道这是否是最佳方法?

#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    char foo[] = { "hola" };
    char test[] = { "test" };
    string foos, tests;
    foos = string(foo);
    tests = string(test); …
Run Code Online (Sandbox Code Playgroud)

c++ arrays concatenation char

6
推荐指数
2
解决办法
6万
查看次数

并行更新2个图片框

我有2个图片框我想并行更新.

现在我有这个:

picturebox_1.Refresh();
picturebox_2.Refresh();
Run Code Online (Sandbox Code Playgroud)

在每个油漆事件中我都有这样的东西:

Picturebox 1:

e.Graphics.Clear(System.Drawing.Color.Black);    
e.Graphics.DrawImage(mybitmap1, X, Y); 
e.Graphics.DrawLine(mypen, verticalstart, verticalend); //Draw Vertical
Run Code Online (Sandbox Code Playgroud)

Picturebox 2:

e.Graphics.Clear(System.Drawing.Color.Black);    
e.Graphics.DrawImage(mybitmap2, X, Y); 
e.Graphics.DrawLine(mypen, verticalstart, verticalend);//Draw Vertical line.
Run Code Online (Sandbox Code Playgroud)

是否有捷径可寻?我是线程等新手.

谢谢!

c# multithreading picturebox

5
推荐指数
1
解决办法
161
查看次数

单击图片框时获取 PixelValue

我正在开发一个 .NET C# 项目,并且希望在单击图片框时获取像素值,如何实现?

基本思想是,当我单击图片框中的任意位置时,我会得到该图像点的像素值。

谢谢!

c# pixel picturebox

4
推荐指数
1
解决办法
2万
查看次数

Loop速度有什么问题?

我有这个简单的for循环,内部没什么.现在运行需要将近2秒,但如果我_img.width用512 替换它,那么它几乎在0.001毫秒内运行.有什么问题?我应该分配一个局部变量而不是使用_img.width吗?我想知道为什么它运行得更快,因为它只是一个数字.

for (int aRowIndex = 0; aRowIndex < _img.width; aRowIndex += subsample)// For por cada fila de cada imagen
{
    for (int aColumnIndex = 0; aColumnIndex < _img.height; aColumnIndex += subsample)//For por cada columna
    {
    }
}
Run Code Online (Sandbox Code Playgroud)

c# performance loops for-loop

4
推荐指数
1
解决办法
154
查看次数

将Math.Pow与Microsoft Solver Foundation一起使用

我正在做一个简单的求解器练习,我正在努力使用Math.Pow.

为什么我不能使用Math.Pow(error1, 2)以下几行?

error1 = error1 * error1;
error2 = error2 * error2;
Run Code Online (Sandbox Code Playgroud)

它给出了一个错误:

错误3参数1:无法从'Microsoft.SolverFoundation.Services.Term'转换为'double'

相关代码:

using Microsoft.SolverFoundation.Common;
using Microsoft.SolverFoundation.Services;

... 

private void Form1_Load(object sender, EventArgs e)
{    
    var solver = SolverContext.GetContext();
    var model = solver.CreateModel();
    Decision R = new Decision(Domain.Real, "R");
    Decision T = new Decision(Domain.Real, "T");
    model.AddDecisions(R);
    model.AddDecisions(T);

    var xr1=5;
    var xr2=4;
    var xp1 = 6;
    var xp2=8;
    var error1 = xr1 * R + T - xp1;
    var error2 = xr2 * R …
Run Code Online (Sandbox Code Playgroud)

c# math solver ms-solver-foundation

2
推荐指数
1
解决办法
583
查看次数

订购数组C#.NET

我有一个DICOM图像列表,并希望按Z顺序排序(它是图像中的属性)

这是我将图像添加到List的代码

  private List<DicomImage> img = new List<DicomImage>();

   for (int i = 0; i < imagenes.Count; i++) //imagenes is a variable that holds the number of images (coming from an OpenFileDialog)
         {

            img.Add(new DicomImage(imagenes[i]));
          }
Run Code Online (Sandbox Code Playgroud)

现在,我如何通过Z命令升序?

假设只需输入以下内容即可访问Z属性:

int Z = img [i] .Z;

c# list

0
推荐指数
1
解决办法
165
查看次数

使用C#后清除数组

我用这种方式在C#中声明了一个数组:

  public ushort[][] pixels16;
Run Code Online (Sandbox Code Playgroud)

然后我用500个图像的像素数据填充它,数组中的每个元素包含262144个项目.问题是,在我使用它之后变得太大所以我需要摆脱它以释放内存..我怎么能这样做?

c# arrays clear

0
推荐指数
2
解决办法
5707
查看次数

ifstream C++无法识别

我正在用C++修改程序,我需要将一些值写入磁盘.

我已经#include <fstream>在Include部分中添加了,然后我尝试使用ifstream但未被识别:

IntelliSense:标识符"ifstream"未定义

我做错了什么?谢谢,

编辑:这是代码

#include <fstream>
#include "stdafx.h"
#include "CommandHandling.h"
#include "Conversions.h"
#include "INIFileRW.h"
#include "ComPortTimeout.h"

CCommandHandling::CCommandHandling()
{
    /* set up com port class, start from new. */
    pCOMPort = NULL;
    pCOMPort = new Comm32Port;
    ifstream test; //Here I get the error cited above
... //More code here
...
...
...

}
Run Code Online (Sandbox Code Playgroud)

c++ ifstream

-3
推荐指数
1
解决办法
1067
查看次数