loop « struct « C Data Type Q&A

Home
C Data Type Q&A
1.binary
2.bit
3.byte
4.char
5.character
6.decimal
7.Development
8.float
9.hex
10.integer
11.prime
12.random
13.struct
C Data Type Q&A » struct » loop 

1. Is there any way to loop through a struct with elements of diferent types in C?    stackoverflow.com

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 ...

2. looping through properties in struct - C    stackoverflow.com

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) ...

3. freeing substring in c - loop    stackoverflow.com

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 ...

4. Storing values in struct objects using c and a do-while loop    stackoverflow.com

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 ...

5. Looping problem in C    stackoverflow.com

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 ...

6. help with structs and looping in C    stackoverflow.com

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 ...

7. For-loop - Structure    stackoverflow.com

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 < ...

8. Help with Looping Structure    bytes.com

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 ...

9. is it possible to access members of struct in loop?    bytes.com

>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 ...

10. saving to multiple struct in while loop    cboard.cprogramming.com

11. Looping struct info    cboard.cprogramming.com

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; ...

12. for loop and struct    cboard.cprogramming.com

#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", ...

13. Problem with do loop in for in my structure in structure program    cboard.cprogramming.com

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 ...

14. while loop structure    cboard.cprogramming.com

#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") == ...

15. Looping switch structure Help (newbie)    cboard.cprogramming.com

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 ...

16. FPUTS-struct node loop.    cboard.cprogramming.com

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); ...

17. loops and structures    cboard.cprogramming.com

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: "); ...

18. combo for loops with if structures    cboard.cprogramming.com

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 ...

19. PROBLEM WITH for loop & structure    forums.devshed.com

#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 ...

20. hostent structure, looping h_addr_list    forums.devshed.com

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.