我需要一些关于任务的一些帮助.
我的任务是创建一个内存区域
void *memory = malloc(320);
Run Code Online (Sandbox Code Playgroud)
然后使用指针将文本存储到这个存储位置:我们想将这个区域划分为32个字节的数据块,母猪我们可以存储:320/32 = 10个数据块,32个字节.在一个数据块中,我可以存储(1个ASCSII char = 1个字节)32个字符.
我有一个10位的位图,其中每个位指示是否使用数据块(1)或不使用(0).
但是,如果我想存储长度为60个字符的文本呢?然后我需要2个数据块(2 x 32字节).位图显示数据块2和6是空闲的,1和6不是并排的.我怎样才能做到这一点?
struct data {
char * text;
};
typedef struct data d;
d->text = ???
Run Code Online (Sandbox Code Playgroud) 我编写了一个实现文件结构的程序,程序根据结构打印出一个产品文件.产品名称包括字母Æ,Ø和Å.这些字母在输出文件中无法正确显示.我用
PrintWriter printer = new PrintWriter(new FileOutputStream(new File("products.txt")));
Run Code Online (Sandbox Code Playgroud)
IS0 8859 - 1或Windows ANSI(CP 1252)是实现需要的字符集.
我想做的是创建一个函数,该函数接受一个参数,该参数是随机生成应该创建的数字的限制.我经历过一些生成器只重复生成一遍又一遍的数字.
如何创建一个不会连续返回相同数字的生成器.有人可以帮助我实现我的目标吗?
int randomGen(int max)
{
int n;
return n;
}
Run Code Online (Sandbox Code Playgroud) 为什么这不编译?无法看到错误
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void)
{
char *c;
FILE *f = fopen("file.txt", "r");
if(f == NULL) {
printf("Could not open file");
}
while((c = fgetc(f)) != EOF) {
if(strcmp(c, " ") == 0) {
printf(" ");
} else if(strcmp(c, ":") == 0) {
printf(":");
} else if(strcmp(c, "@") == 0) {
printf("@");
} else if(strcmp(c, "\n") == 0) {
printf("\n");
} else {
printf("Not a valid char");
}
}
Run Code Online (Sandbox Code Playgroud)
}
当我给出参数print时,为什么我的代码在给我回复"Not a valid command"?
int main(int argc, char *argv[]) {
printf("Argument 2 er %s\n", argv[1]);
if(argv[1] == "print") {
printf("Print kommando kalt");
} else if(argv[1] == "random") {
printf("Random kommando kalt");
} else if(argv[1] == "replace") {
printf("Replace kommando kalt");
} else if(argv[1] == "remove") {
printf("Remove kommando kalt");
} else if(argv[1] == "len") {
printf("øem kommando kalt");
} else {
printf("Ingen gyldig kommando\n");
}
}
Run Code Online (Sandbox Code Playgroud) 我有两个表,我不会查询一些数据.问题是查询永远不会停止,也从不给出任何结果.
任务是获得所有男演员的百分比.
filmparticipation(partid, personid, filmid, parttype)
person(personid, lastname, firstname, gender)
Run Code Online (Sandbox Code Playgroud)
她是我的尝试,有人可以给我一个提示来完成任务吗?
SELECT (COUNT(p.personid) / COUNT(a.person)) * 100
FROM person p, person a, filmparticipation f
WHERE
f.parttype = 'cast' AND
p.gender = 'M';
Run Code Online (Sandbox Code Playgroud) 如何将字符串分成几段?例如,我如何放置“orld”。放入名为 的变量中one,将“Hello”放入名为 的变量中three,并将“w”放入two?
#include <string.h>
#include <stdio.h>
int main(void)
{
char *text ="Hello World."; /*12 C*/
char one[5];
char two[5];
char three[2];
return 1;
}
Run Code Online (Sandbox Code Playgroud) 我想读取并将每一行拆分成一个String数组,每行在每个元素之间有不同数量的空白字符.
如何使用""(空格)作为参数split将行拆分为数组元素?
以下是我要处理的文件类型的示例:
1 Build-walls 4 2 5 0
2 Build-roofs 6 4 0
Run Code Online (Sandbox Code Playgroud)