Hello, I work at the U.S. Department of Labor, on the Unemployment Insurance program. I am working on developing a new Benefit Financing model for the state of Oregon, and I am having an issue with passing a struct between mutiple .c and .cfn files( the .cfn files are for the C cursor screens). The srtuct in question foloews: extern struct{ double x[6][30]; double xtxy[6][5]; double b[6]; double bstde[6]; double tval[6]; double bset[3][6]; double stats[6]; double ajrsq,ystde,ymse,xtra1,xtra2,syy;}regrs_; The struct is declared first in the main .c module, bsyrhd.c, and is further defined in a .cfn called later, invxtx5.cfn. Compiling the …

Member Avatar
Member Avatar
+0 forum 4

Hi All, I below code snippet I have been using diff-2 structure with same variable due to having different -2 default values for the variable (var) in current implementation for both the structure a and b. This way i need to create 17 structure with same variable (var) but different default values. Could you let me know what is the best way to achieve the same with having same sturcture with different-2 values. Apart from this it is very much required to initialize the varaible (var) with default value in structure as it shouldn't be uninitialized. #include <iostream> using namespace …

Member Avatar
Member Avatar
+0 forum 5

I had a function I used a while back to test the pixel colors in a given screen rect, it was something like this pseudo code. for (int y = t; y <= b; y++){ for (int x = l; x <= r; x++){ color = GetPixel(hdc_, x, y) & 0x00FFFFFF; if (color == col){ //cout << "+ " << x << " x " << y << " = " << color << endl << flush; *rx = x; *ry = y; return 1; } } I am wanting to update this code to something, well... better, and faster. …

Member Avatar
Member Avatar
+0 forum 12

This Go snippet calculates the minimum number of bills or coins needed for a given amount of money (change) requested. The program also gives the denomination and number. US curency is used in this example, but can be changed to another currency.

Member Avatar
+1 forum 0

Another little adventure into Go coding. This time a slice (a Go open ended array) of structures is used as a record for some data processing. For those who miss the ; at the end of a line of code, you can use them, but the lexer of the compiler will put them in for you. Go slices are simpler to work with and faster than traditional arrays, even though they use arrays as a backbone. Go was written for efficiency and speed of compilation in mind, it is intolerant of unused imports and unused variables. The reason you will …

Member Avatar
Member Avatar
+1 forum 3

I have the following struct definition: struct finfo { string filename; long fsize; bool operator() (finfo i, finfo j){return (i.fsize > j.fsize);} } fstruct; And the following vector definition: vector<finfo> fdata; In the code I use the following statement to sort the vector elements by fsize: sort(fdata.begin(),fdata.end(),fstruct); This works perfectly well, but how can I sort by the field "filename" when i.fsize = j.fsize ? (The vector is filled by reading directory information, and putting the filenames and filesizes in the appropriate fields in the struct. If the filesize is equal I want to sort the files alphabetically by file …

Member Avatar
Member Avatar
+0 forum 3

I'm working on this code for class, I am not expecting anyone to do my homework but help would be appreciated. Nodes are confusing for me and my professor did not explain well. The errors I am getting are where I declare the functions, I dont know the nodeType(?) that goes in the arguments. Hopefully that makes sense.I think I may have also need to initialize the node? #include <iostream> #include <fstream> #include <string> #include <iomanip> using namespace std; ///employeeType struct, node struct, typedef statement go here. struct employeeType { int idNum; string firstName; string lastName; char gender; double payrate; …

Member Avatar
Member Avatar
+0 forum 1

Hi! I was doing my exercise of C Language. In the exercise I was encountered by a question in which author says you to perdict the correct answer; I was uable to perdict it, so I compiled it to get the answer, the source code is this: #include <stdio.h> int main () { struct { int x, y; }s[] = {10, 20, 15, 25, 8, 75, 6, 2}; int *i; i = s; printf("%d", s[i[7]].x); return 0; } It yields this output: 8 I'm unable to understand why the answer is 8 whereas in my thinking it should be 15. …

Member Avatar
Member Avatar
+0 forum 2

Okay. This weeks 'problem' is that I need to simulate a game. I have to make two singly linked lists which will contain a name of player, his attack (double/float) number and his defence number and so on for as many players as the user inputs. The point of the game is to try to break the other 'chain'. You do that by running into 'enemies' chain and trying to break it, you break it if your attack is greater then defence of two players that you are trying to separete. If you separate them you can pick one of …

Member Avatar
Member Avatar
+0 forum 8

I have a linear array of structs. These are constant structs and is a way of holding a simple table. Now though I need to add another "column" to the table (another member in the definition of the struct) and I'm wondering if I'd be better using a class rather than a struct. Since both structs and classes have constructors I'm wondering which is best to store fixed arrays of data?

Member Avatar
Member Avatar
+0 forum 4

Hi, I have such simple structure in unmanaged C++: struct Cam { char ip[16]; char login[16]; char pass[16]; char name[16]; }; and C# marshalled structure: [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)] public struct Cam { [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] public string ip; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] public string login; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] public string pass; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 16)] public string name; } When I pass C# struct to C++ lib by function [DllImport("NVRLib.dll", CallingConvention = CallingConvention.Cdecl)] public static extern void AddCameraStruct(Cam cam); ... Cam cam = new Cam(); cam.ip = "192.168.0.232"; cam.login = "admin"; cam.pass = "admin"; …

Member Avatar
Member Avatar
+0 forum 1

I wrote a game using an array of structs to represent a 9x9 grid. Now I'm re-writing it as a class to '++ it up' a bit and to better understand classes. Part of the game used a seperate struct to keep track of selected board squares (to see if they match). Would it be proper ettiquete to include a struct as a class member, or is there a more 'proper' way?

Member Avatar
Member Avatar
+0 forum 8

Here's a little program i wrote, i'm trying to pass my structure book to function input. The code works fine on Code::Blocks but VS12 is giving an error on compliation " error C4700: uninitialized local variable 's' used ". What i'm doing wrong? #include <string.h> #include <iostream> using namespace std; struct book{ char title[20]; char author[20]; int price; }; book input(struct book); void display(struct book); book input(book details) { cout << "Book Title : "; gets_s(details.title); cout << "\nBook Author : "; gets_s(details.author); cout << "\nBook : Price : "; cin >> details.price; return details; } void display(book details) { …

Member Avatar
Member Avatar
+0 forum 1

Hello, Am new in Struct I followed link http://www.tutorialspoint.com/struts_2/struts_examples.htm for making simple hello project in struts using eclipse but when i complete the coding and go for the execution, when I write the word in that box as an input (for saying hello). and click on Say Hello button, it gives me error as *HTTP Status 404 - /testpriti/hello -------------------------------------------------------------------------------- type Status report message /<my_project_name>/hello description The requested resource (/my_project_name>/hello) is not available. * I heard by someone that we need to define "method="execute" " which we write in struts.xml file. I dunno how to write this OR this is …

Member Avatar
Member Avatar
+0 forum 3

I'm working on a struct array and I need to dynamically delete elements from the struct. I have the added dynamically but I've run into some issues with deleting. I've researched different methods and tried a few. I found that one from here works, in that it will delete the entry but then using the view function won't print out the new array and crashes. I think it needs to be sorted but when I add my sort function it crashes before returning to the menu. The other method I tried also deleted the element through the index value but …

Member Avatar
Member Avatar
+0 forum 3

I have a void function that takes data from an ifstream, reads the first value, (which is an ID #), and compares that value against the ID# info from an array of records. If it's invalid, the rest of the line is ignored. If it's valid, it adds the hours worked to the hours worked field in an array of records. Here is what the input file looks like: 123 7.5 56 6.25 99 an invalid id 555 2.5 123 10.0 My issue is there is the possibility of multiple entries for the same ID# and for the life of …

Member Avatar
Member Avatar
+0 forum 3

How do I define a typedef struct in function f1() and pass a pointer to function f2() without a global definition of the struct. For instance: Also I would like this to be in C but not in C++. I have no toolbar, so I cannot put the code I had planned. Help with the toobar with getting the edit button would also be great.

Member Avatar
Member Avatar
+0 forum 1

I'm not sure if I'm freeing the memory correctly. I have the following struct and I'm trying to free the pointer in it. typedef struct RECORD { char* name; int score; }RECORD; In my main function I have an array of this struct, therefore I'm using a loop to free it. for(index=0;index<50;index++) { free(report[index].name); report[index].score=NULL; } But then, to test if it worked I print the whole array and I get the following, ╪K3 0 Donald Knuth 0 0 Adele Goldberg 0 0 Brian Kernighan 0 Linus Torvalds 0 ╪K3 0 Grace Hopper 0 ╪K3 0 Peter Norton 0 Bill …

Member Avatar
Member Avatar
+0 forum 2

I'm coding a contact manager using a doubly linked list that is manipulated by functions using pointers that reads in a contactList.txt file.But when I coded the first function to do a search I got the following error list: Error 8 error C2059: syntax error : ')' C:\Users\Brian\Documents\Visual Studio 2010\Projects\G00290342Manager.c\G00290342Manager.c\ContactManager.cpp 9 1 Error 23 error C2065: 'FALSE' : undeclared identifier C:\Users\Brian\Documents\Visual Studio 2010\Projects\G00290342Manager.c\G00290342Manager.c\ContactManager.cpp 142 1 Error 3 error C2065: 'listpointer' : undeclared identifier C:\Users\Brian\Documents\Visual Studio 2010\Projects\G00290342Manager.c\G00290342Manager.c\ContactManager.cpp 9 1 Error 19 error C2065: 'query' : undeclared identifier C:\Users\Brian\Documents\Visual Studio 2010\Projects\G00290342Manager.c\G00290342Manager.c\ContactManager.cpp 38 1 Error 4 error C2065: 'string' : undeclared identifier C:\Users\Brian\Documents\Visual …

Member Avatar
+0 forum 0

I would like to convert a procedural database program that I have created to an object oriented program. In my procedural program I use a struct: struct shoes{ char Name[20]; int Number; double ShoeSize; }; Putting this into a class would I simply use: class Shoes{ public: //Function declerations private: chat Name[20] int Number; double ShoeSize; }; Originally I passed the struct between functions, for example: void view(Shoes *Shoe); Can I do the same with the class? would this pass all the variables or would I have to separetly pass each variable? if not what is the best way to …

Member Avatar
Member Avatar
+0 forum 40

Hi, I've not worked in C, C++ from like 5-6 years. But now I got to do a very small change (explained below). I tried reading tutorials but only got confused. Below I've struct containing 2 attributes. I need to create its refrence and pass values to these 2 attributtes. File in which struct is defined. //List of includes typedef struct dscvs { UPD_TRC(trc_no); UPD_STS(status); }dscvs_i; File in which struct variable is used // Here I need to create a variable of type dscvs_i, so that I can feed the values inside UPD_TRC(trc_no) & UPD_STS(status); // This is what I'm …

Member Avatar
Member Avatar
+0 forum 1

**guys I wrote this, there's no errors, no warnings... but it keeps crashing on execution.. any ideas ?????** #include <stdio.h> #include <stdlib.h> #include <string.h> struct data { char * name ; int grade ; }; int compare_ints(const void *a, const void *b); int compare_strings(const void *x, const void *y); struct data *ptr; static struct data array[5] ; struct data c; //The scanf function receives just memory adress of the " variables ". Not struct definitions... int main(void) { int i=0 ; printf(" Please enter 5 student names and grades: "); for ( i=0;i<5;i++ ) { printf("\n name %d : ",i+1); …

Member Avatar
Member Avatar
+0 forum 3

Develop a telephone directory which is capable of doing the following: 1. Insert a contact 2. Delete a contact 3. Edit an existing contact (changing or modifying a record) 4. Search a contact (and display complete record on screen) a. Search through first name b. Search through last name c. Search through landline d. Search through cell number 5. Display all contacts that: a. Start with a given letter (e.g., all contacts starting with ‘M’) b. Landline or cell number starting with a particular pattern (e.g., 0300 for cell number, or (042)3518 for landline number) 6. Sort all contacts with …

Member Avatar
Member Avatar
+0 forum 26

Hey guys, So I've thoroughly gone through the topics by searching this site but I couldn't find something which can help me. I'm making a task for my friend and let me tell you that it's been a year or more since I've used C++. I've moved on to C# and JAVA. So the problem I'm facing is with pointers and returning struct through pointer. Here's the code below: #include <stdio.h> #include <conio.h> #include <iostream.h> struct student { int SUB[3]; }; struct AVGPCT { float avg; float pct; }; AVGPCT* CALC(student *A) { int x,y; AVGPCT D[5]={0.0,0.0,0.0,0.0,0.0}; for(x=0;x<5;x++) { for(y=0;y<3;y++) …

Member Avatar
Member Avatar
+0 forum 3

typedef struct zoz { int age; int mag; int suly; } nevsor_t; int olvas(nevsor_t * pnevsor) { return scanf("%d %d %d", &pnevsor->age, &pnevsor->mag, &pnevsor->suly); } int kiir(nevsor_t nevsor) { return printf("%d year\t%d cm\t%d kg\n", nevsor.age, nevsor.mag, nevsor.suly); } int sort_age(const void *a, const void *b) { struct nevsor_t *ia = (struct nevsor_t *)a; struct nevsor_t *ib = (struct nevsor_t *)b; return *ia->age - *ib->age; } I want to sort the elements of block tomb by age which is the first variable of struct nevsor_t. The elements are added manually from the keyboard: int main() { int i,n; nevsor_t tomb[50]; nevsor_t …

Member Avatar
Member Avatar
+0 forum 1

Hi. Im trying to write a simple deck of cards program. I am having difficulty in expressing my integer deck into a printable form. The deck is generated as this: 00102030405060708090100110120011121314151617181911011111210212223242526272829210211212203132333435363738393103113123 The leading numbers assign to suits and the following number assign to card rank. Basically how can I convert this to print in the form: Card 1: Ace of spades Card 2: 2 of spades Card 3: 3 of spades etc; Could I use if statements and BREAKS to change the ints into strings? Perhaps a char value for suit would be better.. Any suggestions? Any help would be …

Member Avatar
Member Avatar
+0 forum 7

hello everyone i'm new ic and i have a problem on structs, on the very simple i want to create a struct with one int and a char table 3 potisions,this is my code #include <stdio.h> #include <string.h> #include <conio.h> struct domi { int code; char name[3]; }; main() { struct domi don; int i; printf("Dwse times gia ta meloi tis domis "); scanf("%d",&(don.code)); for (i=0;i<3;i++) { // don.name[i]=getchar(); scanf("%c",&(don.name[i])); } printf("Oi times pou dwsate einai: %d kai ",don.code); for (i=0;i<3;i++) { printf("%c",(don.name[i])); } } i want to put on my keyboard the values 5 a b c and it …

Member Avatar
Member Avatar
+0 forum 3

Hi everyone, I'm currently working on a school assignment and came up with this error saying 'list_t has no member named head' but when I actually look at list.h and list.c (my code accessing list is in a separate file), head is in list.c. What did I do wrong? list.c typedef struct node node_t; struct list { node_t *head; }; struct node { void *data; node_t *next; }; list.h typedef struct list list_t; flange.c vector_t start; vector_t end; list_t *params = datacons_params(shape); list_t *tempList = tuple_val((value_t *)list_nth(params, 0)); start.x = tempList->head->data; start.x = tempList->head->next->data; and tuple_val returns `(list_t *val)`

Member Avatar
Member Avatar
+0 forum 3

The question asks: Write and compile a C++ program that simulates the arrivals of airplanes at Regina airport. An airplane is represented using a C++ struct. Each plane belongs to an airline, such as United, and records the city from which it is arriving, for example Chicago. The airport is an ADT that holds all of the arrivals at the airport. These arrivals are stored in an array. Boolean functions are needed to test whether or not there are any arrivals or if the arrivals terminal is full (4 airplanes). A function to add a new arrival to the airport …

Member Avatar
Member Avatar
+0 forum 6

How do you read a input file into a structure in c++? Say for example you have an input file with 5 names. And a structure such as struct{ string student; int grade; }; The input file is structured like: Justin Williams 95 Tracy Williams 34 How do I get the names and the respective grade into the structure? Thanks.

Member Avatar
Member Avatar
+0 forum 1

The End.