109 Topics

Member Avatar for
Member Avatar for jwill222

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 …

Member Avatar for WaltP
0
140
Member Avatar for dancks

So, I'm using allegro game programming library. Before I move on to bigger and better things I wnat to get a handle on pointers. Specifically with things like structs, linked lists and maybe binary trees in the future. I posted a program that uses a linked list to keep tracks …

Member Avatar for dancks
0
301
Member Avatar for Vish0203

Hi everyone, I'm facing problem in deleting a node in **del()** used in my program. Suppose, i've added a city as **Delhi**, and at the time of deleting, i type the name as **delhi**, the compiler gives a processor fault. But, i want it to display the line number **95**. …

Member Avatar for Sokurenko
0
284
Member Avatar for hwoarang69

so the code is pretty simple. it just loops and if statements. first i have a main. i took the headers and prototypes out to make it smaller. In main all iam doing is asking user to enter command and call one funtion. // main.c int main(int argc, char *argv[]) …

Member Avatar for WaltP
0
174
Member Avatar for tischn

Hi i had never before used structures, so i am a complete noob ;) . this is a small Part of my programm: struct player { int var1; int var2; int var3; int var4[10]; int var5; int var6; }; struct player p[4]= {{1000,0,0,{0,0,0,0,0,0,0,0,0,0},0,1}, {1000,0,0,{0,0,0,0,0,0,0,0,0,0},0,1}, {1000,0,0,{0,0,0,0,0,0,0,0,0,0},0,1}, {1000,0,0,{0,0,0,0,0,0,0,0,0,0},0,1}}; printf("%d\n"), p[0].var1; printf("%d\n"), p[0].var2; …

Member Avatar for tischn
0
136
Member Avatar for The Blacklist

#include<stdio.h> #include<stdlib.h> struct student{ char *name; int number; }; struct class{ char *name; struct student *st_array; // pointer of array of students int size; // All students free places int current_size; // Occupied places }; struct student make_student(char name[100], int number){ struct student st; st.name = name; st.number = number; …

Member Avatar for TrustyTony
0
284
Member Avatar for CodeNinjaMike

So, basically im using the codea bove to generate coordinates for a grid, but I only want to generate coordinates for the "outer ring" of a square. SO imagine a grid of 7x7, I won't generate coordinates for the inner 5x5 square, only for the outer ring. Basically I drew …

0
580
Member Avatar for Vish0203

I wrote this program... Just gave a try!! i got a problem with searching a string in file.. the **"checkp"** used in the login function, returns a value **"1"**, whereas it must return a value **"0"** Hence my program fails... what i felt is, the file i'm opening, **"web_reg.txt"**, in …

Member Avatar for Vish0203
0
185
Member Avatar for hwoarang69

iam trying to store all the data in to a struct so i can change it later. //this data is in file abc 1 11 22 def 2 33 ghi 0 22 11 33 asd 2 i was planing on making a array of structs. so 1st line will have …

Member Avatar for hwoarang69
0
220
Member Avatar for _hp_

Does anyone knows how to assigned directly the sqlite query result to a struct in C rather that assigning to its members one by one? I have a table user_info with fields user_id, username, password. Also I have a struct st_user_info. typedef struct st_user_info{ int userId; char* userName; char* password; …

Member Avatar for Ancient Dragon
0
243
Member Avatar for coolbits

I want to create a struct array and get the max number of books written by particular author...The problem is that i can't get the number. I am not finished up yet with the code,but i don't know why i am not getting anything when calling the Max function.Please advise! …

Member Avatar for coolbits
0
144
Member Avatar for animeocarl

can you help me with these a little problem of mine.. we are having a pair project where the program is all about enrollment system. in this program, we need to add a record, view, and search records. now. my problem is... i cannot add another record within this code... …

Member Avatar for Ancient Dragon
0
218
Member Avatar for abed1986

Hello everyone, I have a program that intends to create a doubly linked list of structures, using the following header (q1.h): [CODE=c]typedef struct lNode* ListNodePtr; typedef struct lNode { char* string; ListNodePtr next; ListNodePtr prev; } ListNode; [/CODE] This is my implementation: [CODE=c]#include "q1.h" #include <stdio.h> #include <stdlib.h> #include <string.h> …

Member Avatar for abed1986
0
803
Member Avatar for benclifford

Hi, I have a task to perform which all to do with the smurfs, reading from a file and doing some simple stuff to it. The last part I need to do is print out a list of all smurfs and their corresponding role in alphabetical order. I am hoping …

0
225
Member Avatar for linezero

[CODE]#include <stdio.h> #include <stdlib.h> #include <string.h> //typedef struct to define what's in the phonebook typedef struct PhoneBookContacts { char Name[20]; char Surname[20]; char PhoneNumber[20]; } phone; //Function prototypes void AddEntry (phone[]); void DeleteEntry (phone[]); void PrintEntry (phone[]); void Sort (phone[]); int counter = 0; //Global counter variable used to keep …

Member Avatar for savoie
1
23K
Member Avatar for mBrissman

Hello! I have a problem. I can't use scanf() to set a value of the second member of the person struct. Why? I get an error that tells me "bad access". [CODE]int main(int argc, const char * argv[]) { struct Adress{ char *street; char *postal; int zip; }; struct Person{ …

Member Avatar for mBrissman
0
1K
Member Avatar for linezero

Hi Programmers, Please help me, i was wondering on how to create a simple phone book program using struct array to insert a new contact, update an existing contact, delete an existing contact and to display the contact information

Member Avatar for zeroliken
0
952
Member Avatar for scottd82

Hey everyone, I wrote some code to create a deck of cards, described the deck and randomly deals 5 cards. First, I want to let everyone know that this is homework for my C-II college class, so I am not looking for any answers, but solutions or guidance in figuring …

Member Avatar for WaltP
0
1K
Member Avatar for Ich bin würdig

Hi guys ! I've made a program that marks a seat taken X in an airplane .. So, here's what I've done.. it runs , but when i try to input other seat code, i.e., 1G, the no.2 in the grid becomes 88.. and I don't know how did that …

Member Avatar for zeroliken
0
116
Member Avatar for vincenzorm117

I have been having trouble developing a function that frees all of the memory associated with structs of a linked list. Im not asking for a clear cut answer, just an idea or a function that can aid. F.Y.I. the linked list contains a head struct and a tail struct …

Member Avatar for sorry711
0
236
Member Avatar for eavila

Hey, so as you can tell, this is my first attempt at writing a class. I put in a mock int main() in order to follow what exactly is going wrong. As far as I can tell, every time the struct in push is used, it always has the same …

Member Avatar for gusano79
0
142
Member Avatar for cool_zephyr

Hello there..i'm trying to implement a tree in C#..the basic node structure is give below [code] struct node { public int _x; public int _y; public int _cost; public node _parent; public pos(int i, int j,int cost,pos parent) { _x = i; _y = j; _cost = cst; _parent = …

Member Avatar for cool_zephyr
0
155
Member Avatar for smallrubberfeet

Hello all, I'm having a bit of trouble logically figuring out what to do in this case for my cs150 class. I have to create a linked list from a while loop, but I can't figure out how to link the list successively at the end of each line so …

Member Avatar for Clinton Portis
0
2K
Member Avatar for A&M_guy

I am new to structs and I am trying to sort an array of structs but I can't seem to get it to work, I can't figure out what I am doing wrong and any assistance would be very much appreciated! [CODE]#include <iostream> #include <fstream> #include <iomanip> using namespace std; …

Member Avatar for A&M_guy
0
264
Member Avatar for janet@123

i am receiving a struct from the switch: [CODE]/* Packet received on port (datapath -> controller). */ struct ofp_packet_in { struct ofp_header header; uint32_t buffer_id; /* ID assigned by datapath. */ uint16_t total_len; /* Full length of frame. */ uint16_t in_port; /* Port on which frame was received. */ uint8_t …

Member Avatar for janet@123
0
264
Member Avatar for valestrom

Hi, I'm trying to make a set of monsters that have values that can be loaded. Like a Goblin having enemyhealth = 50, enemydamage = 15, etc. Here's what I kinda have an idea of doing... But I really have no idea how to use it. (File containing values for …

Member Avatar for valestrom
0
289
Member Avatar for C++newbie chick

Hi guys, what I'm trying to do is allow the user to add a new student record to the system. If the user inputs a student ID already existing in the system, it doesn't accept the ID, but if it's a new student ID, it asks the user if they …

Member Avatar for raptr_dflo
0
248
Member Avatar for C++newbie chick

Hello guys, just wondering why my program crashes when I try to delete a struct from my array. I'm trying to code so that the user searches for a student via a student ID, then opt to delete the searched student's record. I thought I got it right and the …

Member Avatar for chandara
0
847
Member Avatar for Cainer

Hi, I am using WinSock library for sending data over network, and I have a problem. I know how to send data in one struct and receive it on the other side, because there is constant size of structure. But what if I have more structures, each one with different …

Member Avatar for Cainer
0
556
Member Avatar for Macilath

Howdy, I have a few questions regarding the use of ctime within a class. I followed the example on [URL="http://www.cplusplus.com/reference/clibrary/ctime/strftime/"]http://www.cplusplus.com/reference/clibrary/ctime/strftime/[/URL] When the program is like this, it works: [CODE] #include <ctime> #include <iostream> using namespace std; int main(){ time_t current_seconds; current_seconds = time(NULL); //Fills current_seconds with the number of seconds …

Member Avatar for Macilath
0
683

The End.