structure

How to Initialize structure that includes unique items out of multiple elements

限于喜欢 提交于 2020-01-05 05:47:28
问题 I have 4 arrays that represent: Colour (r , g, b, y) Shape (A , B , C, D) Number (1 , 2 , 3, 4) Texture (a, b , c, d) and also each array can have 4 values. I want to have in an array all the possible combinations of all these elements. For example rA1a, rB1a,rC1a and so on. I am thinking of creating a structure and then somehow create these 256 elements of the structure. However I am totally blind to how I can do this—I mean create the 256 elements ! Can someone please point me in the right

C program - Structure marked as undeclared in compiler

亡梦爱人 提交于 2020-01-05 04:16:09
问题 I am trying to write a program to collect security information about a file and convert it to human readable information. However, I am facing a problem with initializing a pointer to structure: #include <stdio.h> #include <aclapi.h> #pragma comment(lib, "advapi32.lib") struct file_perms { char user_domain[2050]; unsigned long user_mask; }; static myfunc (){ PSECURITY_DESCRIPTOR pSD = NULL; PACL pDACL = NULL; char *file = "D:/code/test.c"; ACL_SIZE_INFORMATION aclSize; ULONG result =

reading a text file into a structure

守給你的承諾、 提交于 2020-01-05 03:35:54
问题 my text file is like this (the data in the file can also increase) 822 172.28.6.56 172.34.34.53 3244 5434 844 192.150.160.145 192.67.45.123 2344 234 700 192.13.56.6 192.89.95.3 4356 3566 522 172.28.6.137 172.28.6.110 2543 5245 900 255.255.255.255 244.244.244.244 2435 3245 and my structure is like this struct input_par { int key_node; char src_ip[15]; char dst_ip[15]; int src_port; int dst_port; }; i have to fill this struture from data stored in file, once it completes inputting the 5

SML/NJ: How to use HashTable?

不想你离开。 提交于 2020-01-04 14:27:06
问题 I really want to create a HashTable in SML, it seems there already is a structure for this in SML/NJ. The question is, how do I use it? I've not fully understood how to use structures in SML, and some of the very basic examples in the book I read gives me errors I don't even know how to correct, so using the HashTable structure might be an easy thing, but I wouldn't know. If someone could explain this, then that'd be wonderful too! I'm thinking it's something like this: val ht : string * int

For a structure variable,why is the initializer {21,19,3.6} same as {{21,19},3.6},but not vice-versa?

限于喜欢 提交于 2020-01-04 01:20:32
问题 In the following example,I've illustrated this using two structures test1 and test2 .The first has two elements-an integer array sized two,and a float element.The second structure has 3 elements,2 integers and one float. I initialize two structure variables s1 and s2 for test1 as: s1={{23,52},2.5},s2={21,19,3.6}; Both work fine even though for s2 I have taken out the braces that enclose the array elements.It works fine without warning and output is correct.But when I initialize 2 variables

Matlab structure in Python [duplicate]

落花浮王杯 提交于 2020-01-03 05:34:26
问题 This question already has an answer here : Matlab struct array to python (1 answer) Closed 5 years ago . Is there any variable in python similar to Matlab structures? I would like to create a structure within another structure as in Matlab, but in Python. I've looking into Python Dictionaries, but I have not find an easy way to access to its values. Which in Matlab is really easy. In Matlab I would do the following: Create the structure structure.parent1.variable1 = 23; structure.parent1

Difference between Class and Structure in PHP and Java

对着背影说爱祢 提交于 2020-01-03 05:13:17
问题 What is real difference between Class and Structure when you are dealing with Object Oriented Programming. This question is asked many times during my interviews for SE. Some people says that there is only one difference: Structure members are public by default and Class members are private by default. Some says there are many differences. After reading many articles and forums, I have the following differences: Classes DEFAULT to having private members. Structures DEFAULT to having public

read same structure on all threads

末鹿安然 提交于 2020-01-03 03:40:12
问题 I want all threads to read from the same structure. I did it in the past by adding threads inside the loop which reads from the structure but this time I need the structure to be opened inside void "dowork" as my example shows. I have the following code: struct word_list { char word[20]; struct word_list * next; }; struct word_list * first_word = NULL; //other function which loads into struct is missing cause it's not relevant //in main() pthread_t thread_id[MAX_THREADS]; int max_thread = 10;

Python structure always stuck at 0 no matter what value you assign to it?

≯℡__Kan透↙ 提交于 2020-01-02 08:24:33
问题 I was writing a module to compact bits to be passed to C program, but keep getting errors. After some tests, I found out that the field a of class Blah is stuck at 0 no matter what. Does anyone know if this is a bug or if I'm doing something wrong here? Sorry, I forgot to mention I'm using python 3.1.2 from http://www.python.org/download/releases/3.1.2/ >>> import ctypes >>> class Blah(ctypes.Structure): ... _fields_ = [("a", ctypes.c_uint64, 64), ... ("b", ctypes.c_uint16, 16), ... ("c",

Properties in Structures: “Expression is a value and therefore cannot be the target of an assignment.”

我的未来我决定 提交于 2020-01-02 02:01:30
问题 I have the following 2 structures, and I don't really understand why the second one does not work: Module Module1 Sub Main() Dim myHuman As HumanStruct myHuman.Left.Length = 70 myHuman.Right.Length = 70 Dim myHuman1 As HumanStruct1 myHuman1.Left.Length = 70 myHuman1.Right.Length = 70 End Sub Structure HandStruct Dim Length As Integer End Structure Structure HumanStruct Dim Left As HandStruct Dim Right As HandStruct End Structure Structure HumanStruct1 Dim Left As HandStruct Private _Right As