my struct is some like this
typedef struct {
type1 thing;
type2 thing2;
...
typeN thingN;
} my_struct
how to enumerate struct childrens in a loop such as ... |
Can I use a forloop to get the property names of a "struct" in C? Or would I just have make a separate list? (Just the name I am looking for)
... |
I'm trying to get a sub-string for each member of the struct 'structs' and then assign that sub-string to a new member of the temp_struct.
The problem I'm having is how ... |
I'm trying to store a few values in a struct object and I want to repeat the prompt until the user types in "yes". I want to use a do-while loop ... |
I am writing a simple program in c so I can understand better the language but I have a strange problem.
As you see from the code below I have only one ... |
beginner in C here. Is this legal here? I keep getting status access violation when i run this code:
struct point {
char *x;
char *y;
}
int ...
|
I have this part of code:
for(i = 0; i < matrix->y; i++)
{
printf("3.%i - %i %i\n", i, matrix->y, matrix->x);//write correct "3.0 - 3 4"
for(j = 0; j < ...
|
|
I have a programming assignment I've been working on for class. Basically the program creates a design of "+'s" based on user's input of how many rows he or she would like displayed. Here is a basic example of what the output may look like if someone requested there be 6 rows of design: + ++ +++ +++ ++ + I ... |
>is it possible to access the members of a struct (e.g. 10 members) in a[color=blue] >loop, comparable to an array?[/color] If you're expecting to iterate over the members of unknown name and type, NO. You can make a table of the member names, types, and offset (using offsetof()), and use that, but you have to keep it up to date with ... |
|
Currently my code outputs to what I want it to do (print out everyone's given name) shown below: Code: #include main() { struct acct { int accountNumber; char givenName[20]; char familyName[30]; char streetAddress[40]; char city[20]; char phoneNumber[12]; float balance; }; struct allAccounts { struct acct a000001; struct acct a000002; struct acct a000003; struct acct a000004; struct acct a000005; struct acct a000006; ... |
#include #include struct flight_str { char flt_no[30]; char flt_orgin[4]; char flt_dest[4]; char flt_dept_t[5]; char flt_ariv_t[5]; }; typedef struct flight_str flight; void flts_from(char dept_aport[4], flight flights[]) { int counter; for (counter = 0; counter < sizeof(flights); ++counter) { if (strcmp(flights[counter].flt_orgin, dept_aport) == 0) { printf("Flight %s\n", flights[counter].flt_no); } } } int main() { flight flight_a[10]; strcpy(flight_a[0].flt_no,"12432"); strcpy(flight_a[0].flt_orgin,"LAX"); strcpy(flight_a[1].flt_no,"55555"); strcpy(flight_a[1].flt_orgin,"BOS"); flts_from("BOS", ... |
it doesn't give me syntax error but compile error... i notice it's from my for loop "specifically the do to input a name " i want to know how i can fix this problem in my do if anyone can help me.. Code: #include // This program is a structure which in structure task im doing in class //THe problem ... |
#include #include int main ( void ) { char studnam[20]; for ( ;; ) { printf("Please enter the first and last name of the student: "); fflush(stdout); if ( fgets(studnam, sizeof studnam, stdin) ) { char *newline = studnam + (strlen(studnam) - 1); if ( *newline == '\n' ) { *newline = '\0'; } if ( strcmp(studnam, "bye") == ... |
Hello, I'm doing the "currency conversion program" that you all have seen a million times already. I coded the program and it runs. When invalid choice is made from my "menu" it ends the program (pick 1-6 and someone picks 9). what I'm wanting to do is to loop the switch so that if user picks "9" it will printf "Please ... |
I have to make a programm that among others outputs a text stored in a struct node (line by line), in a file. I use fputs. Here is the function PrintFile that prints the file: Code: void WriteFile(struct list *buffer, char *filename) { char line[MAXLINE]; FILE *fp; fp=fopen(filename,"w"); if (fp==NULL) { printf("Den einai dinaton, na ginei eggrafi sto arxeio %s!", filename); ... |
Hello, I made a small structure in order to see how loops work with them and I'm getting some weird results. Could someone look and see my mistakes. [code]/* #include #include void main(void) { struct grade { char class_name[20]; char name[20] ; }; struct grade stu_record[2]; int i; char repeat; for(repeat=0;repeat<2;repeat++) { printf("\nEnter class name: "); scanf("%s",stu_record[repeat].class_name); printf("\nEnter student name: "); ... |
okay, i'm trying to make a for loop that will run from 1 to the number of records i've entered in a previous while loop then i'm making calculations based on the number of things they buy (more you buy, less unit cost) here's my code, my output is very confusing as it just lists a slew of numbers after each ... |
#include typedef struct { char name [20]; int ID,year; char major [4]; float GPA; }data; /************************* Main FUNCTION ********************************/ int id,num=0; int i,d; data a[100]; for(i=0;i<100;i++)// error wHY ?? a[i].ID =0; // Error WHy? do { printf(" \n Welcome in the student data base \n\n"); printf("\n\t\t\t 1. Add new student "); printf("\n\t\t\t 2. Update student "); printf("\n\t\t\t 3. Display student ... |
|