Hey guys, I would like some help regarding saving or reading to or from a bin file. I've read several online tutorials about file input/output, however it doesn't given specific information when applying it to both an array of structures. My knowledge of pointers is weak, as I constantly need to look over examples to get an idea of whats going on. Heres my attempt: [CODE] #define PLANET_SIZE 10 /* Called from function */ save(planet_t writePlanet[], *totalSize); /* define as int* totalSize */ read(planet_t *writePlanet); typedef struct{ char name[20]; }planet_t; /* Save to file */ void save(planet_t writePlanet[], int totalSize){ …

Member Avatar
Member Avatar
+0 forum 7

I have a large database of tennis match reords played in the ATP and WTA tours over several years. I am going through these to generate a match history for each player in each year in each tour. I have 5 years of data and 4 tours (hence the dimensions in the declaration below). I want to do a typedef not just for these specified dimensions, but in general so I can declare another Array2DPlayerHistoryMap object, but if I don't put in a dimension the compiler compains. How can I do the 2nd and 3rd lines for the general case? …

Member Avatar
Member Avatar
+0 forum 1

Is this a "typedef" problem? This is the definition in one file. typedef BYTE SOCKET; //Socket descriptor BYTE is defined elsewhere as type char. (I made sure the file where SOCKET is assigned a type is included in the file the problem is in.) This is one place it is used but my compiler is saying "BerkeleyTCPServerDemo.c:83:19: error: 'bsdServerSocket' undeclared (first use in this function)" in the following (line 83 equates to the third line in this excerpt)... void BerkeleyTCPServerDemo(void) { static SOCKET bsdServerSocket; static SOCKET ClientSock[MAX_CLIENT]; struct sockaddr_in addr; struct sockaddr_in addRemote; int addrlen = sizeof(struct sockaddr_in); char bfr[15]; …

Member Avatar
Member Avatar
+0 forum 6

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 had a doubt in one of the usages of typedef. I want to know the meaning of this line: typedef char Text[80]; What is the meaning of this line and what does it do? Does it create an array of typedefs relating to char, or does it mean "Text means a string of size 80". Thank you in advance! :D

Member Avatar
Member Avatar
+0 forum 2

My understanding of the C language is that the same identifier cannot be reused. However, the code below compiles on GCC without complaints, even when using the "-Wall -pedantic" flags. Is there something that I am missing? Does the standard say anything about functions/macros having the same name as typedef'd types? #include <stdio.h> typedef int error; #define init() error var_error = -6 #define error() ((const error)var_error) int main(void) { init(); printf("error() = %d\n", error()); return 0; }

Member Avatar
Member Avatar
+0 forum 2

Hi there, As the title says, I'm having an issue passing an array of structures to a function.The structure reads and tokenises information from a text file. I then need to do things with that data using several different functions. Here's my code: #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct{ char carID[4]; char carType[8]; int engineSize; char bodyType[9]; int numSeats; char transType[9]; int mileage; char available; } cars_t; int main() { cars_t cars[8]; char line[100]; char line2[100]; char *nextWordPtr; int count = 0; FILE *ptr_cars; ptr_cars = fopen("cars.txt", "r"); while ( fgets ( line, sizeof line, ptr_cars ) != …

Member Avatar
Member Avatar
+0 forum 3

Hi all. I am trying to build a Binary Linked Trie but fail in basic pointer operations.Following code can be built but in debug or run mode, it breaks and outputs the error. [ICODE]typedef struct node { char ch; node *next; }; struct node *root = NULL; void add(struct node *leaf, char ch) { leaf = new node; leaf->ch = ch; leaf->next = NULL; } void read() { while(root->next != NULL) cout << root->ch; } int _tmain(int argc, _TCHAR* argv[]) { struct node *conductor; add(root, 'a'); conductor->ch = 'l'; conductor->next = NULL; root->next = conductor; read(); return 0; }[/ICODE] The …

Member Avatar
Member Avatar
+0 forum 3

Hi, I am trying to make a bank application that has two interfaces.One is the employee interface that lets employees to create an account and assign a IDnumber to each account(lets say the bank only accepts 100 accounts) and a balance for each account. The employee can also close an account in the employee interface by entering the IDnumber. Now in the clients interface the user can enter the IDnumber of an account and after searching the IDnumbers created by the employees it lets the user the deposit,withdraw or show the account information such as balance. I am not sure …

Member Avatar
Member Avatar
+0 forum 3

Hi. As far as I know, [B]typedef[/B] is used to assign an alias for a structure or type of data, am I wrong? Is there something more to know about Typedef? thanks

Member Avatar
Member Avatar
+0 forum 2

The End.