我想使用套接字,TCP/IP通信在c#(windows窗体)中创建聊天应用程序客户端应该向服务器发送文本,服务器应该响应,当服务器向客户端发送消息时,客户端必须接收该消息.所有发送都应该在按钮点击事件上执行.如果有人工作过,请帮助我,我是socket编程的新手.
你好伙计我只是java语言的初学者.我的程序是java中的多级继承,使用构造函数.我在编译我的程序时面临一些错误.如果任何人在这里解决我的问题,我会感觉很好.
class bee
{
int x,y,z;
bee(int x1,int y1,int z1)
{
x=x1;
y=y1;
z=z1;
}
void vol()
{
int vol1=x*y*z;
System.out.println("Volume1="+vol1);
}
}
class be extends bee
{
be(int x2,int y2,int z2)
{
x=x2;
y=y2;
z=z2;
}
}
class inh3
{
public static void main(String args[])
{
be c=new be(10,20,30);
c.vol();
}
}
Run Code Online (Sandbox Code Playgroud) 代码优先:
#include <stdio.h>
void foo()
{
static int bar;
}
int main()
{
bar++;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
编译器(Clang)抱怨:
static.c:10:2: error: use of undeclared identifier 'bar'
Run Code Online (Sandbox Code Playgroud)
该语句static int bar;中是否应该foo()给出bar静态存储持续时间,这使得它在main函数之前声明并初始化?
目前正在使用我的DirectX游戏并在常量缓冲区构造函数中使用memset(0)(或VS中的ZeroMemory宏)来使用零初始化所有值,并且它可以正常工作.当我不小心尝试以这种方式初始化包含向量的其他结构时出现问题.根据编译器(VS2010/VS2012),这会导致"矢量迭代器不兼容",std :: vector :: end更加精确.我可以理解memset可能会使向量迭代器无效,但是在我将元素推回到向量之后,为什么"结束"迭代器无法正常工作.它不应该重新定位向量将迭代器结束到正确的位置(在最后一个元素之后)?所有类型的std :: some_container :: end迭代器都受此影响了吗?
#include <vector>
class MyClass
{
public:
MyClass() {
memset(this, 0, sizeof(*this));
}
~MyClass() {}
std::vector<int>& GetData() { return m_data; }
float m_range;
private:
std::vector<int> m_data;
};
int main()
{
MyClass myClass;
myClass.GetData().push_back(1);
myClass.GetData().push_back(2);
for (auto it = myClass.GetData().begin(); it != myClass.GetData().end(); it++)
{
//stuff
}
}
Run Code Online (Sandbox Code Playgroud) 我通常知道,*和&符号.但我们的老师给了我们一个例子,她说"问题发生在这里"
int *a1;
int *a2 = new int[100];
a1=a2 //What does this line mean???
delete []a2;
k=a1[0]//she said error occurs here.
Run Code Online (Sandbox Code Playgroud)
我无法理解什么是a1 = a2?为什么会出现错误?
我正在尝试编写一个C代码,它将在屏幕上打印金字塔结构,就像这样.

我写的相应代码是这样的.
#include <stdio.h>
#include <stdlib.h>
void printArrayFunc(char arr[9][5])
{
int i,j;
printf("=========================================\nprinting the values\n");
for (i = 0; i<5; i++)
{
for (j = 0; j<9;j++)
{
//printf("arr[%d][%d] = %d\n", i,j, arr[i][j]);
if (arr[i][j] == 1)
printf("*");
else
printf(" ");
}
printf("\n");
}
}
int main()
{
int i,j;
char arr[9][5] = {0};
printf("============================\nfilling the values\n") ;
for (i=0;i<5;i++)
{
for (j= 4-i;j<=4+i;j++)
{
arr[i][j] = 1;
// printf("arr[%d][%d]= %d\n",i,j,arr[i][j]);
}
//printf("\n");
}
printArrayFunc(arr);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
它给出了类似的输出

我知道我犯了一些愚蠢的错误,但此时此刻,我无法找到出错的地方.让我听听你对此的评论.
我是R.的新手.我在一个文件夹中有超过300个CSV文件(名为001.csv,002.csv等).每个包含一个带标题的数据框.我正在编写一个函数,它将采用三个参数:文件的位置,要计算平均值的列的名称(在数据框内)以及要在计算中使用的文件.
这是我的功能:
pollutantmean2 <- function(directory = getwd(), pollutant, id = 1:332) {
# add one or two zeros to ID so that they match the CSV file names
filenames <- sprintf("%03d.csv", id)
# path to specdata folder
# if no path is provided, default is working directory
filedir <- file.path(directory, filenames)
# get the data from selected ID or IDs from the specified path
dataset <- read.csv(filedir, header = TRUE)
# calculate mean removing all NAs
polmean <- mean(dataset$pollutant, na.rm …Run Code Online (Sandbox Code Playgroud) 你不能只使用指针存储尽可能多的数据吗?你为什么要malloc()用来获得更多的记忆?
int * a;
int max, i;
printf("Enter the maximum number you want: ");
scanf("%d", &max);
for (i = 0; i < max; i++)
{
* (a + i) = i;
}
for (i = 0; i < max; i++)
{
printf("%d\n", * (a + i));
}
return 0;
Run Code Online (Sandbox Code Playgroud)
所以我让用户选择任何数字,计算机将"分配内存"吧?而不是使用以下代码:
a = (int *) malloc(10 * sizeof(int));
Run Code Online (Sandbox Code Playgroud)