标签: structure

有关取消引用结构指针的问题

我正在编译这段代码,我得到编译错误,说"解除指向不完整类型的指针".我得到了最后一个print语句的错误,在此之前我尝试指向(*temp).num到b的地址

void main()
{

    struct {
        int xx;
        char *y;
        int * num;
        struct x *next;
    }x;

    struct x* temp;
    int b = 10;

    temp = ((struct x *)malloc(sizeof(x)));

    (*temp).num = &b;

    x.next = temp ;

    printf(" %d\n",temp->num, x.next->num);

}
Run Code Online (Sandbox Code Playgroud)

c pointers structure dereference

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

如何从正确的位置调用CSS文件

我正在用PHP开始一个项目,我想从一开始就正确地构建我的文件(不像我上一个项目,几乎每个文件都在一个目录中).问题如下,我将用一个例子来描述:

获取以下文件:index.php,includes/header.php和css/common.css.index.php'包含'标题(和许多其他php文件一样).然后标头调用common.css,以便可以正确放置其html元素.common.css还将为index.php和其他文件中的常规元素提供样式.

请注意,由于包含头部,当头部调用common.css时,它会从调用的文件位置执行此操作; 在这种情况下,index.php.但是,如果我添加,例如,modules/friends.php并用它调用标题,它将在错误的位置寻找CSS文件!

最初我试图通过使用实际路径来解决这个问题,当我调用CSS文件时.但是,我的本地计算机和Web服务器具有不同的目录布局,因此我不能简单地调用/ var/www/whatever.

任何人都可以帮助我或将我重定向到记录此类事情的地方吗?

谢谢,

模范

css php structure file

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

为什么我们使用new关键字初始化结构虽然它是一个值类型

为什么我们使用new关键字初始化结构,即使它是C#中的值类型?

c# structure

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

jQuery:构建多div结构

我想用jQuery构建这个html结构:

<div id="container">
    <div id="row0">
        <div id="start0"></div>
        <div id="end0"></div>
    </div>
    <div id="row1">
        <div id="start1"></div>
        <div id="end1"></div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

这就是我所做的,但它是丑陋的,没有按预期工作.你能帮我么.谢谢.

var count = 0;
$("#target").click(function() {
    $('#container').append($('<div></div>')
                    .attr({ id : "row" + count })
                    .addClass("test"));

    for (var i = 0; i < 2; i++) {
        $("#row" + count).append('<div id="start' + count + '</div');
        $("#row" + count).append('<div id="end' + count + '</div');
    } 
    count++;
});
Run Code Online (Sandbox Code Playgroud)

html jquery structure

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

解释包含结构的联合的sizeof运算符的结果

#include<stdio.h>
struct mystruct
{
    char cc;
    float abc;
};
union sample
{
    int a;
    float b;
    char c;
    double d;
    struct mystruct s1;
};
int main()
{
    union sample u1;
    int k;
    u1.s1.abc=5.5;
    u1.s1.cc='a';

    printf("\n%c %f\n",u1.s1.cc,u1.s1.abc);
    k=sizeof(union sample);
    printf("%d\n\n",k);
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

运算符的大小正在返回8我仍然能够访问结构元素,一次不止一个,并且sizeof运算符仍然返回我假设的原始数据类型的最大大小.为什么会这样?实际分配的大小是8?并且sizeof返回错误的值?或者实际分配的大小是8?那么结构是如何适应的?如果我们使用分配一个联合数组mallocsizeof在这种情况下分配足够的空间吗?请详细说明.

c structure sizeof unions

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

我的C程序已停止工作

我正在尝试在这里完成我的作业,即写一个程序,它显示了一定数量点的距离(0,0).但是出于某些原因,我的程序启动后,Windows表示它已停止工作.我尝试了两个不同的编译器,他们没有给我任何错误消息.

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

struct point {
    int x;
    int y;
};

struct point getPoint();
void printPoint(struct point);
double distanceToO(struct point p);
void createArray(struct point, int);

int main() {

    int number, i;
    struct point coord[number];

    printf("Type the number of points you want to create: ");
    scanf("%d", &number);

    printf("\n\n");

    for(i=0;i<number;i++)
        coord[i]=getPoint();

    printf("\n\t\tPoint\tDistance to (0,0)\n");

    for(i=0;i<number;i++) {        
        printPoint(coord[i]);

        printf("\t%0.2lf", distanceToO(coord[i]));
    }

    system("pause"); 
    return 0;
}

struct point getPoint() {
    struct point p;

    printf("Type the x and the y-value for …
Run Code Online (Sandbox Code Playgroud)

c structure

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

结构总是以C中的分号结尾

我有两种结构.首先是:

struct complex {
    double real, imaginary;
};
Run Code Online (Sandbox Code Playgroud)

我知道它必须用分号结束.

但这一个具有功能

struct complex add_complex(struct complex c1, struct complex c2) {
    struct complex c3;
    c3.real = c1.real + c2.real;
    c3.imaginary = c1.imaginary + c2.imaginary;
    return c3;
}
Run Code Online (Sandbox Code Playgroud)

如果我最后没有包含分号,那么编译器将不会生成错误.为什么?

c structure

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

c排序大型struct数组并打印到屏幕

我在排序结构数组然后将其打印到屏幕时遇到问题.当我在Visual Studio 2012中运行代码时,它不会打印全部.我花了好几个小时搞清楚,调试模式很麻烦.我真的需要知道为什么它没有做我告诉它做的事情.

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

struct RandStruct
{
int year;
char string[31];
int frequency;
};

struct RandStruct randArray[150000];

int main(void)
{

int i, j;

for (i = 0; i < 150000; i++)
{
    randArray[i].year = 150000 - i;
    strcpy(randArray[i].string, "test");
    randArray[i].frequency = i;
}

for (i = 1; i < 150000; i++)
{
    for (j = 0; j < 150000 - i; j++)
    {
        if (randArray[j].year > randArray[j+1].year)
        {
            struct RandStruct temp = randArray[j];
            randArray[j] = …
Run Code Online (Sandbox Code Playgroud)

c arrays sorting struct structure

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

含义:变量<-struct {} {}

我不明白double {}的含义.这在任何学习材料中都没有明确说明.谢谢.

variable <-struct {}{} 
Run Code Online (Sandbox Code Playgroud)

structure go channels

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

如何在C++中引用类结构中的函数?

我想使用返回struct aa类型的getSth函数main().你能让我知道推荐的方式吗?

//info.h
namespace nsp {
  class A {
    struct Info {
      struct aa {
        std::string str;
        int num;
        aa(): num(0) {}
      };
      std::vector<aa> aas;
      aa getSth();
    };
  };
}

//info.cpp
A::Info::aa A::Info::getSth() {
aa ret;
for(auto &tmp: aas) {
  if(ret.num < aas.num)
    ret.num = aas.num;
}
return ret;
}

// main.cpp
#include info.h
namepace nsp {
  class A;
}
int main()
{
  nsp::A *instance = new nsp::A();
  // How can I refer getSth using "instance"? …
Run Code Online (Sandbox Code Playgroud)

c++ structure class function

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

标签 统计

structure ×10

c ×5

arrays ×1

c# ×1

c++ ×1

channels ×1

class ×1

css ×1

dereference ×1

file ×1

function ×1

go ×1

html ×1

jquery ×1

php ×1

pointers ×1

sizeof ×1

sorting ×1

struct ×1

unions ×1