structure

From file to structure in C

丶灬走出姿态 提交于 2019-12-23 04:06:18
问题 I am trying to write from file to structure in C. Whenever I try to assign value in structure it gives me error: incompatible types in assignment. My structure looks like this: struct competition{ char eventTitle[79]; char date[79]; char time[79]; }; Basically I want to open the file and assign individual line to different value in structure. ie. first line in file -> eventTitle, second line -> date, third line -> time. Here is how I try to assign it: FILE *naDaSt; char *mode = "r"; int lines

p is a pointer to a structure, what do all these code snippets do?

谁说胖子不能爱 提交于 2019-12-23 03:06:17
问题 ++p->i p++->i *p->i *p->i++ (*p->i)++ *p++->i I don't understand these statements above, I wrote a small test program to understand them. #include <stdio.h> struct my_structure { int i; }; void main() { struct my_structure variable = {20}; struct my_structure *p = &variable; printf("NAME: %d\n", ++p->i); printf("NUMBER: %d\n", p++->i); printf("RANK: %d", *p->i++); printf("name: %d\n", *p->i++); printf("number: %d\n", (*p->i)++); printf("rank: %d", *p++->i); } Here's what the output I got

What is the difference between structures containing bool vs uint when using PInvoke?

半城伤御伤魂 提交于 2019-12-22 22:53:28
问题 Ok, I'm now very confused. After my last question had several people comment about changing bool to uint I verified they are the same size by: Console.WriteLine("sizeof bool = {0}", Marshal.SizeOf(typeof(bool))); Console.WriteLine("sizeof uint = {0}", Marshal.SizeOf(typeof(uint))); Which of course prints: sizeof bool = 4 sizeof uint = 4 That said, I then broke down and gave their suggestions a try anyway... Changing a single bool inside a structure to a uint. What I can't figure out for the

nested structure array access in python using SWIG

本小妞迷上赌 提交于 2019-12-22 17:54:46
问题 I haven't been able to figure out how to access the array elements SubStatus in the following nested structure. I do seem to be able to see the first element, but don't understand how to force indexing, e.g., as a list. Any help is much appreciated. status.h: // Data Types typedef char CHAR; // 8 bits signed typedef short SHORT; // 16 bits signed typedef long LONG; // 32 bits signed typedef unsigned char UCHAR; // 8 bits unsigned typedef unsigned short USHORT; // 16 bits usigned #define FUNC

SVN project structure

徘徊边缘 提交于 2019-12-22 10:54:25
问题 We are moving to SVN from VSS and are debating the project structure. We are debating two proposals displayed below. No. 1 seems simpler for development support since a Project release version is tied to a tag and the developer would only need to perform an update on that tag to immediately get to work. No. 2 insures that all Projects and Dependencies can be developed independently but building a particular release version means knowing the tags of the Project and all it's Dependencies. Are

C - Change all values of an array of structures in one line

邮差的信 提交于 2019-12-22 10:35:39
问题 I can declare a structure: typedef struct { int var1; int var2; int var3; } test_t; Then create an array of those structs structure with default values: test_t theTest[2] = { {1,2,3}, {4,5,6} }; But after I've created the array, is there any way to change the values in the same way I did above, using only one line, specifying every value explicitly without a loop? 回答1: In C99 you can assign each structure in a single line. I don't think that you can assign the array of structs in one line

how to print structure value(like gdb ptype) automatically in C?

不打扰是莪最后的温柔 提交于 2019-12-22 09:01:04
问题 This question stay in my head for a long time. As we know, we can easily print data structure in GDB when we debugging, like gdb ptype command, it can output all field value of structure. I know GDB use bfd library to read symbolic information in object file. My question is: if I want to do this in my C source code, how to do? because I don't want to printf each field of structure one by one. Is there have any exist library to solve this issue? I think that library will not only meets my

How to resolve two structures with the same name?

坚强是说给别人听的谎言 提交于 2019-12-22 05:28:59
问题 In my code base I find that two modules have structures with the same name. It is giving a name conflict error. Is there a way to resolve it without changing the code? 回答1: This is a terrible hack, but it would be possible to use a macro to redefine the name of the struct, like so // a.h struct collide { int a; }; // b.h struct collide { float b; }; // test.c #define collide a_collide #include "a.h" #undef collide #include "b.h" int main(){ struct a_collide a; struct collide b; return 0; }

java library to maintain database structure

余生颓废 提交于 2019-12-22 03:52:41
问题 My application is always developing, so occasionally - when the version upgrades - some tables need to be created/altered/deleted, some data modified, etc. Generally some sql code needs to be executed. Is there a Java library that can be used to keep my database structure up to date (by analyzing something like " db structure version " information and executing custom sql to code to update from one version to another)? Also it would be great to have some basic actions (like add/remove column)

Executing Core Data saving on a background thread?

纵然是瞬间 提交于 2019-12-22 00:41:54
问题 I've got a button which marks a selected entry in a Core Data SQLite as a "Favourite", meaning I'm just flipping a BOOL for that index from off to on. Currently, when I do this, I call save on the managedObjectContext , which takes maybe 500ms, perhaps a little more, according to Instruments. I have some code that executes at the same time which triggers a nifty little particle explosion ("Hooray, a favourite!"), but I'm running into an issue where that explosion is delayed until after the