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

Recommended Answers

All 3 Replies

int readVal(struct Telem* tm)
{
  scanf("%d%d%d", &tm->entrytime, &tm->cust_num, &tm->waitime);
}

>>Ancient dragon

int readVal(struct Telem* tm)

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

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);
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.