小编Kri*_*hna的帖子

将KVM(针对Linux)移植到Mac OS X.

我正在尝试将KVM(写于Linux)移植到Mac OS X.


后台工作:我开始浏览Apple Developer Documents,其中列出了执行此操作的过程.我无法理解它的某些部分,而我理解和尝试的部分并不能很好地工作(按计划).正如Apple Developer文档所建议的那样,我也尝试过fink,macports等.但是,一旦代码在主机上成功编译,这些包管理应用程序就会出现,对吗?(这就是我的假设).*如果我错了,请纠正我.现在,我正在逐一消除所面临的错误.这种方法花费了大量的时间和精力,而且,我不知道,这是否会起作用.


问题:请告诉我我的方法是对还是错.如果正确,请告诉我下一步应该是什么.如果错了,请告诉我应该是我的第一步. PS:为项目分配的大量时间已经妄图尝试不同的方法.请帮助我采取明确的方法来解决这个问题.

macos kvm

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

Adding a clone of an object to a list in c# (prevent modification from outside)

I have an object like 'obj1' which I want to add to a list. I can add it by just list1.add(obj1) .Now once I update obj1, the object in my list is also updating! (I understand that I am dealing with references here)

My requirement demands modifying the obj1 and add it to the list again! Instead of having two different objects, I have only one, because for both of them, the reference is the same - obj1. …

c# reference pass-by-reference

5
推荐指数
2
解决办法
7594
查看次数

使用C中的筛选方法列出最多20亿的素数

我尝试使用Sieve Eratosthenes方法列出最多20亿的素数.这是我用的!

我面临的问题是,我无法超过1000万个数字.当我尝试时,它说"分段错误".我在互联网上搜索找到原因.有些网站说,这是编译器本身的内存分配限制.有人说,这是硬件限制.我使用的是安装了4GB RAM的64位处理器.请建议我列出它们的方法.

#include <stdio.h>
#include <stdlib.h>

#define MAX 1000000
long int mark[MAX] = {0};

int isone(){
   long int i;
   long int cnt = 0;
   for(i = 0; i < MAX ; i++){
      if(mark[i] == 1)
         cnt++;
   }
   if(cnt == MAX)
      return 1;
   else
      return 0;
}



int main(int argc,char* argv[]){
   long int list[MAX];
   long int s = 2;
   long int i;
   for(i = 0 ; i < MAX ; i++){
      list[i] = s;
      s++;
   }
   s = 2; …
Run Code Online (Sandbox Code Playgroud)

c arrays primes segmentation-fault sieve-of-eratosthenes

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

指向结构指针的指针

我有一个如图所示的结构.当我有一个指向结构的指针时,我能够正常初始化或修改它的任何成员.

struct node{
    int key;
    int nno;
    char color;
    struct node* out;
    struct node* next;
    struct node* pre;
};
Run Code Online (Sandbox Code Playgroud)

但是,当我将结构指针的地址传递给函数并使用双指针捕获它时,并尝试使用该双指针访问成员时,我的编译器抛出错误'member undefined'.

void DFSVisit(struct node** u){
    *u->color = 'g';
    struct node* v;
    while(*u->out != NULL){
            v = *u->out;
                    if(v->color == 'w'){
                            v->pre = *u;
                            DFSVisit(&v);
                    }
    } 
    *u->color = 'b';
}
Run Code Online (Sandbox Code Playgroud)

而且,这就是我访问该功能的方式.

DFSVisit(&root);
Run Code Online (Sandbox Code Playgroud)

Root是正确初始化的指针.而且,Root是一个全局变量.

c pointers structure

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

C中的QSORT功能

在下面的代码中,一旦我删除了比较字符串的注释部分,我就会遇到seg 11错误.我无法理解为什么!其余的代码工作正常.任何帮助表示赞赏!

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int compare_scores_desc(const void* scorea, const void* scoreb){
int a = *(int*)scorea;
int b = *(int*)scoreb;
return a-b;
}

int compare_names(const void* namea, const void* nameb){
char** a = *(char**)namea;
char** b = *(char**)nameb;
return strcmp(*a,*b);
}

int main(int argc, char* argv[]){
int scores[7] = {456,234,65,563,67,19,100};
int i;
qsort(scores,7,sizeof(int),compare_scores_desc);
puts("\nThese are the scores in order : \n");
for(i=0;i<7;i++)
    printf("%i\n",scores[i]);
char *names[] = {"Krishna","Rama","Bhishma","Arjuna"};
/*qsort(names,4,sizeof(char*),compare_names);*/
puts("------------------");
puts("The names in order are : \n");
for(i=0;i<4;i++) …
Run Code Online (Sandbox Code Playgroud)

c pointers qsort

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