structure

How do I start a new Perl module distribution?

怎甘沉沦 提交于 2019-12-12 07:57:10
问题 I'm trying to set up a large-ish project, written in Perl. The IBM MakeMaker tutorial has been very helpful so far, but I don't understand how to link all the modules into the main program. In my project root, I have MANIFEST , Makefile.PL , README , a bin directory, and a lib directory. In my bin directory, I have my main script ( Main.pl ). In the lib directory, I have each of my modules, divided up into their own respective directories (i.e. Utils::Util1 and Utils::Utils2 in the utils

Can anyone help me with the explanation of the processing of this snippet of code

落爺英雄遲暮 提交于 2019-12-12 06:58:37
问题 Actually i compiled this in a online c compiler, the output of the code was 5... how did the processing take place?? #include <stdio.h> int main() { struct ab {char a,b;}; union abcd { int c; struct ab d; }k; k.d.a=5; k.d.b=0; printf("%d",k.c); } 回答1: you have an union between an integer and a structure containing 2 chars. The code is changing the first char of the structure. Because of the union, it affects the first byte of the other union member, which is the integer. On a little-endian

Why isn't scanf( ) waiting for input from keyboard?

妖精的绣舞 提交于 2019-12-12 05:27:53
问题 I have below C code. #include<stdio.h> int main() { //Declaring structure book. struct book { char name; float price; int pages; }; struct book b[5]; int i; //Below loop takes the info if 5 books from user for (i=0; i<5; i++) { printf("Enter name, price, and pages: "); fflush( stdin ); scanf("%c%f%d",&b[i].name,&b[i].price,&b[i].pages); } return 0; } However when I compile and run, something strange happens. -bash-4.1$ ./a.out Enter name, price, and pages: A 23 34 Enter name, price, and pages

python ctype recursive structures

余生长醉 提交于 2019-12-12 04:54:50
问题 I've developped a DLL for a driver in C. I wrote a test program in C++ and the DLL works fine. Now I'd like to interract with this DLL using Python. I've successfully hidden most of the user defined C structures but there is one point where I have to use C structures. I'm rather new to python so I may get things wrong. My approach is to redefine a few structures in python using ctype then pass the variable to my DLL. However in these class I have a custom linked list which contains recursive

include() messing up HTML structure

我是研究僧i 提交于 2019-12-12 04:38:10
问题 I have a little problem. I have header.php and footer.php files which I include in every page. In the header.php I have the <head> tag with the scripts/styles and a div which is the top bar. In the footer.php I have closing tags. <?php include('header.php'); ?> <div class="content"> <!-- CONTENT --> </div> <?php include('footer.php'); ?> The problem is when I structure a page like the code above, my code is messed up, here is a picture http://img13.imageshack.us/img13/9640/92571581.jpg As you

scheme structures and lists

匆匆过客 提交于 2019-12-12 04:35:22
问题 (define-struct position (name numshares share-price)) (define p1 (cons (make-position "INT" 10 192) (cons (make-position "SSS" 4 42) empty))) mult is my helper function (define (mult n) ( * (position-numshares n) (position-share-price n))) const takes the position-numshares and the position-share-price in a list and multiplies them together. (define (const n) (cond [(empty? n) empty] [(cons? n) (+ (mult (first n)) )])) What I would like to do is take the first of the list and add the rest of

Linked list head address changes C

馋奶兔 提交于 2019-12-12 04:33:43
问题 I created linked list of my structure, but for some reason every time I add another link it changes head address, but I want y head address be first entry. this is my code: struct checkPoints *tgh = NULL; struct checkPoints **linkedlist = &tgh; struct checkPoints *cp = malloc(sizeof (struct checkPoints)); chPo = fopen(fileName, mode); if (chPo == NULL) { printf("Can't find the files."); exit(1); } else { for (i = 0; i < lines; i++) { fscanf(chPo, "%c %d %d %d:%d\n", &cp->dropOut, &cp-

XTC file reading error

倾然丶 夕夏残阳落幕 提交于 2019-12-12 04:20:04
问题 #include "xdrfile/xdrfile_xtc.h" #include "xdrfile/xdrfile.h" #include<stdio.h> int main() { int nat; int step; float time; float prec; int status; matrix box; rvec k[3]; XDRFILE* xfp=xdrfile_open("test2.xtc","r"); status=read_xtc(xfp,nat,&step,&time,box,k,&prec); xdrfile_close(xfp); return 0; } I tried to run the code using the xtc library to read a trajectory frame of GROMACS... I am getting an error, Segmentation error Can you please help??? 回答1: Looking at this code Second parameter nat

Compare and edit underlying structure in hash

戏子无情 提交于 2019-12-12 03:57:47
问题 I have a hash of complex structure and I want to perform a search and replace. The first hash is like the following: $VAR1 = { abc => { 123 => ["xx", "yy", "zy"], 456 => ["ab", "cd", "ef"] }, def => { 659 => ["wx", "yg", "kl"], 456 => ["as", "sd", "df"] }, mno => { 987 => ["lk", "dm", "sd"] }, } and I want to iteratively search for all '123'/'456' elements, and if a match is found, I need to do a comparison of the sublayer, i.e. of ['ab','cd','ef'] and ['as','sd','df'] and in this case, keep

Copying variables of one inner struct to other inner struct using a function that takes address of one inner struct as a parameter

≯℡__Kan透↙ 提交于 2019-12-12 02:58:58
问题 I have a complex structure which looks like this. struct a { struct b { int b_inner_int; char b_inner_char; }x; struct c { int c_inner_int; char c_inner_char; }y; }z; I use a function, that takes address of "struct c" as an argument. Now I want this function to copy the values of "struct c" to "struct b". The function call that I make in the main function may look like this. copy_val(&z.y); Now, how do I define copy_val? Any suggestions? If i define a pointer of type struct c, like below it