sizeof

.NET DateTime Does Not Have a Predefined Size

狂风中的少年 提交于 2019-12-10 13:56:29
问题 Since DateTime is a struct with members that appear to break down into simple mathematical values, I'm not sure why using sizeof() on it produces the message in the question title. 回答1: Because the CLR can only determine the size at runtime... one of the reasons for this is "padding" (platform dependent)... For all other types, including structs, the sizeof operator can be used only in unsafe code blocks. Although you can use the Marshal.SizeOf method, the value returned by this method is not

以您熟悉的编程语言为例完成一个hello/hi的简单的网络聊天程序——网络程序设计课第二次作业

巧了我就是萌 提交于 2019-12-10 13:37:17
  本次作业主要是使用自己熟悉的语言完成一个简单的socket编程,并对比该语言的socket api和linux api之间的异同。因此我将先附上socket程序的代码,并分析socket api,与linux api加以比较 我使用的是winsock,C++语言,基于流套接字(TCP)。 server端: #include <iostream> #include<string> #include <winsock2.h> #include <winsock.h> #include<string> #include<thread> #pragma comment(lib,"WS2_32.lib") using namespace std; static WSADATA wsaData; //wsadata结构包含有关windows套接字实现的信息 static SOCKET serversocket; //服务器socket static SOCKET clientsocket; //客户端socket static sockaddr_in sockin; //保存地址信息 int len = sizeof(SOCKADDR); //地址长度 char text[100]; //接收消息缓冲区 struct sockaddr_in sa; //客户端地址信息 int len

Find out the size of a polymorphic object

南笙酒味 提交于 2019-12-10 12:55:49
问题 I have an pointer Base* base_ptr to an polymorphic object. Is it possible to find out the size of the dynamic type of said object? AFAIK, sizeof(*base_ptr) yilds the size of the static type of base_ptr . I'm beginning to suspect this isn't possible, but maybe I'm overlooking something. Note: I'm aware that I could add a virtual function to my type hierarchy which returns the size, but this is not a desirable solution in my case. EDIT: sizeof(base_ptr) -> sizeof(*base_ptr) 回答1: No, you can't

How to use `sizeof` operator inside the condition of for-loop properly? [closed]

心不动则不痛 提交于 2019-12-10 12:26:22
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 months ago . Do the conditions of the for-loop always need constant? How can I put sizeof function there to run an output showing all the elements of an array? #include<iostream> using namespace std; void array_output(int a[]) { for (int i = 0; i < (sizeof(a)) / (sizeof(a[0])); i++) { cout << a[i] << endl; } } int main() {

Simple 'database' in c++

狂风中的少年 提交于 2019-12-10 12:17:47
问题 My task was to create pseudodatabase in c++. There are 3 tables given, that store name(char*), age(int), and sex (bool). Write a program allowing to : - add new data to the tables - show all records - sort tables with criteria : - name increasing/decreasing - age increasing/decreasing - sex Using function templates is a must. Also size of arrays must be variable, depending on the amount of records. I have some code but there are still problems there. Here's what I have: Function tabSize() for

sizeof a pointer

浪子不回头ぞ 提交于 2019-12-10 10:54:28
问题 int i=0; int *p = &i; std::cout<<sizeof(i)<<" vs "<<sizeof(p)<<"\n"; char c='0'; char*pc = &c; std::cout<<sizeof(c)<<" vs "<<sizeof(pc)<<"\n"; double d=0.123456789; double *pd = &d; std::cout<<sizeof(d)<<" vs "<<sizeof(pd)<<"\n"; Why is the size of a pointer always equal to that of an integer which is 4? 回答1: Because that is how much memory a pointer takes: 4 bytes. If this was a 64-bit application, it would return 8. 回答2: Pointers don't contain the data they point to. Pointers just point to

What am I missing in the following program?

时光怂恿深爱的人放手 提交于 2019-12-10 10:47:45
问题 #include<stdio.h> #define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0])) int array[] = {23, 34, 12, 17, 204, 99, 16}; int main() { int d; for (d = -1; d <= (TOTAL_ELEMENTS - 2); d++) printf("%d\n", array[d + 1]); return 0; } Why is the for loop not run even once? 回答1: The issue is that sizeof() returns size_t which is unsigned. Comparison of -1 with TOTAL_ELEMENTS - 2 should result in a warning indicating you have compared unsigned with signed. When this comparison happens, the -1 is

C语言课设-单位车辆调度管理

不羁岁月 提交于 2019-12-10 07:16:46
单位车辆信息包括:车牌号、车型、载重(客)量,车牌,生产厂家,出厂日期,购买日期,购买单价等;车辆调度信息还应包括:用车人,用车单位,调度人,出车车牌,出车司机,出车用途,出车日期,出车时间,收车日期,收车时间及出车费用等信息等。设计“车辆调度管理系统”,使之能提供以下功能: 系统以菜单方式工作; 车辆调度信息录入功能(车辆调度信息用文件vehicle.txt保存); 车辆信息及车辆调度信息浏览功能; 车辆调度查询和排序功能: 车辆信息及车辆调度信息的删除与修改等功能。 代码如下,完全原创,代码功能完整!! #include <stdio.h> #include <stdlib.h> #include <string.h> #include <windows.h> int feature;//定义输入的功能选项 char now_date[12];//定义系统当前日期存储缓冲区 SYSTEMTIME sys; //定义系统时间变量 //定义车辆数据结构 typedef struct Vehicle { char *ver_id;//定义车辆编号 char *ver_no;//定义车辆牌号 char *weight;//定义车辆对应载重量 char *ver_trand;//定义车牌 char *factory;//定义车辆生产厂家 char *outdate;//定义车辆出厂日期

四种比较简单的图像显著性区域特征提取方法原理及实现-----> AC/HC/LC/FT。

别等时光非礼了梦想. 提交于 2019-12-10 04:02:44
laviewpbt 2014.8.4 编辑 Email: laviewpbt@sina.com QQ:33184777   最近闲来蛋痛,看了一些显著性检测的文章,只是简单的看看,并没有深入的研究,以下将研究的一些收获和经验共享。 先从最简单的最容易实现的算法说起吧:    1、 LC算法   参考论文: Visual Attention Detection in Video Sequences Using Spatiotemporal Cues 。 Yun Zhai and Mubarak Shah. Page 4-5。 算法原理部分见论文的第四第五页。 When viewers watch a video sequence, they are attracted not only by the interesting events, but also sometimes by the interesting objects in still images. This is referred as the spatial attention. Based on the psychological studies, human perception system is sensitive to the contrast of visual signals, such as