小编cra*_*str的帖子

我可以设置例如array [n + k] = array [0]吗?

如果我有这个代码:

#include <iostream>

using namespace std;

int main()
{
    int n, i;
    cin >> n;
    float array10[n];
    cin >> array10[i];
}
Run Code Online (Sandbox Code Playgroud)

如何创建array10[n+1]和设置值array10[0]

c++ arrays

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

IEnumerable 返回类型 C# C++

我有一个带有如下方法签名的 C# 接口:

IEnumerable<string> Myfun();
Run Code Online (Sandbox Code Playgroud)

在 C++/CLR 中,接收返回字符串的数据类型是什么?

我努力了

IEnumerable<std::string> ^abc = myObject.Myfun();
Run Code Online (Sandbox Code Playgroud)

我收到此错误:错误 C3225:“T”的泛型类型参数不能是“std::string”,它必须是值类型或引用类型的句柄

c# ienumerable c++-cli return-type

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

保存数组地址的指针地址如何相同?

p是一个整数指针,可以保存int变量的地址,但它也有一个内存地址 - 存储它的位置.

a = 1002 指针的数组地址的基地址p = 2008

当我们写:int *p=a; //p points to the base address of array a
int **r=&p; //means *r points to the address of p

如何*r指向地址a,它应该指向地址p.

#include <stdio.h>
void main()
{
    int a[3] = {1, 2, 3};
    int *p =a;
    int **r = &p;
    printf("%p %p", *r, a);
}
Run Code Online (Sandbox Code Playgroud)

c c++ arrays pointers

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

Visual C# - 缺少部分修饰符

我收到一个错误,说"在类型'projectName.Main'的声明中缺少部分修饰符;此类型的另一个部分声明存在.从我可以读到的关于此错误的内容,因为我有相同名称的类.如果我有效将主类修改为公共部分类Main:Form但我想知道它为什么会给我这个错误.我需要在Main()中初始化Component,尝试创建一个方法start()然后在一个加载中调用main.Start()事件,但然后表单加载空白.

namespace projectName
{
    public class Main : Form
    {
        public Main() // Method: Starts the main form
        {
            InitializeComponent();
        }

        public void Main_Load(object sender, EventArgs e)
        // On load of main class, handle events and arguments
        {
            Main main = new Main();
            main.getCurrentDomain();
        }

        public void getCurrentDomain() // Method: Get current domain
        {
            Domain domain = Domain.GetCurrentDomain();
        }
    } // Ends the main class
}
Run Code Online (Sandbox Code Playgroud)

.net c#

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

Python 中的简单“if”语句

我很难让这个简单的 if 语句起作用。我正在尝试使用“if”语句将字符串打印一定次数

x = 0
if x < 9:
    print "this works"
    x = x + 1
else:
    print "this doesn't work"
Run Code Online (Sandbox Code Playgroud)

上面代码的结果是它只打印了一次“this works”。我希望将 1 添加到 x 直到 x 达到 9 并且该语句不再正确。

有人能帮我一下吗?

python if-statement

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

c ++链表怪编译错误

我正在尝试使用以下代码在C++中创建链接列表

int main ()
{
    return 0;
}

class LList
{
private:
    struct node
    {
        int value;
        node *follower;  // node definitely is a node
    };

    node m_list;
    int m_length;
public:
    LList ();
    void insert (int index, int value);
    int get_length () const { return m_length; }
};

LList::LList ()
{
    m_length = 0;
    m_list.follower = 0;
}
void LList::insert (int index, int value)
{
    node *cur_node = &m_list;
    for (int count=0; count<index; count++)
    {
        cur_node = cur_node.follower;  // << …
Run Code Online (Sandbox Code Playgroud)

c++ linked-list

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

(DWORD),*(DWORD*)和(DWORD*)之间有什么区别?

标题中的问题也是如此......

什么之间的区别(DWORD),*(DWORD*)以及(DWORD*)

一个例子:

#include <windows.h>
#define playerpointer 0xABC12375 // example

int main()
{
    DWORD dwPlayerPtr = *(DWORD*)(playerpointer);
}
Run Code Online (Sandbox Code Playgroud)

希望你能帮我...

c++ pointers dword

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

为什么我的C项目编译无法找到我的结构?

我有一个基于单个C文件的项目,我尝试重新排列以便在几个.c和.h文件中进一步开发.

我的主要内容如下:

// General includes

typedef struct 
{
} MyStruct;

#include "MyInclude.h"

// Rest of the code
Run Code Online (Sandbox Code Playgroud)

我的文件"MyInclude.c"的结构如下:

#include "MyInclude.h"

// Defines

// Functions that need to know MyStruct
Run Code Online (Sandbox Code Playgroud)

关于海湾合作委员会的编制过程,我有些不明白.事实上,我得到错误"MyStruct未声明(在此函数中首次使用)"并且我不知道为什么我在我的结构的typedef声明之后放入了我的include.

有人知道它为什么会发生吗?

c struct compilation

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

通过阅读字符跳过空白区域

我想跳过字符之间的空格.例如,我有这个:

abc def ghi,那么输出必须是:

a = 1
b = 1
c = 1..etc
Run Code Online (Sandbox Code Playgroud)

但现在我得到:

"" = 2.
Run Code Online (Sandbox Code Playgroud)

因为角色之间有两个空格.

我试试这样:

SortedDictionary<char, int> dictionary = new SortedDictionary<char, int>();

Console.WriteLine("Enter a string: "); // prompt for user input
string input = Console.ReadLine(); // get input

// split input text into tokens
char[] letters = Regex.Split(input.ToCharArray().ToString(), @"\s+");
Run Code Online (Sandbox Code Playgroud)

c#

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

使用win32 api的常用自定义控件

我一直在网上搜索关于win32 API的不同内容,但似乎所有关于它的信息都相当稀疏.

我希望创建一个简单的窗口,显示rss feed,我想独立于MFC,Windows窗体和WPF等技术,所以我需要在win32中,所以我将在任何应用程序中显示它.指导我如何可能.

c++ winapi

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

Why runtime error occur when we try to get the length of the NULL string?

Why the following code gives an error?

 // This a CPP Program 
#include <bits/stdc++.h> 
using namespace std; 
  

// Driver code 
 main() 
{ 
    string s=NULL;
    s.length();
}
Run Code Online (Sandbox Code Playgroud)

I know that a runtime error will occur because I am trying to get the length of the null string but I want to know why it is happening?

c++ string pointers

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