0

i have a function that works for integers.
e.g.

typedef int Telem;

int readValue(Telem *testdata)
{ 
    if (scanf("%d", testdata)!= 1)
        return 0;
    else return 1;
}

now i converted the integer into a struct

typedef struct Telem{
    int entrytime;  
    int cust_num;   
    int waitime;    
};

how will i call this function now?and how i will use scanf for all the members of the struct?

thank u

Edited by Nick Evan: Fixed formatting

3
Contributors
3
Replies
5
Views
6 Years
Discussion Span
Last Post by Ancient Dragon
0
int readVal(struct Telem* tm)
{
  scanf("%d%d%d", &tm->entrytime, &tm->cust_num, &tm->waitime);
}

Edited by Ancient Dragon: n/a

0

>>Ancient dragon

int readVal(struct Telem* tm)

Can you explain this ? because telem is itself a structure.
sorry..
Got it.

Edited by Arbus: n/a

0

The word "struct" should not have been there because Telem is a typedef name not a structure name.

you create an object of that structure in some other function then pass a pointer to it, just like passing a pointer to an integer that you posted in your original post to this thread. Example:

int readVal(Telem* tm)
{
   // blabla
}

int main()
{
   Telem tm;
   readVariables(&tm);
}

Edited by Ancient Dragon: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.