Solved

How to return these variables

Posted on 1999-01-20
2
162 Views
Last Modified: 2010-04-15
I would like to create a function like this which works on sql api:

char szName[10];
int nCount;

...
SQLBindCol( hStmt, 1, SQL_C_CHAR, szName, sizeof( szName ), NULL );
SQLBindCol( hStmt, 2, SQL_LONG, &nCount, 0, NULL );
SQLFetch( ... );

The variables szName & nCount is not assigned until SQLFetch() is called.  How is the function able to send this values back to me?  Can someone write a small sample for the two on how it does this.

Thanks
0
Comment
Question by:eric07
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
idt earned 30 total points
ID: 1258230
when you pass the address of the variable, the function can change the values pointed to, and so after the function returns, the values are set.

eg

void main(void) {
    char foo[16];
    x=smackfoo(foo);
    printf(%s",foo);
   }

int smackfoo(char *zoo) {
  int moo=64;
  sprintf(zoo,"yakity %d",moo);
  return 0;
  }



-iDT



0
 

Author Comment

by:eric07
ID: 1258231
How would you do a numeric value?  I understand the char but not quite sure about the number.
.
SQLBindCol( hStmt, 2, SQL_LONG, &nCount, 0, NULL );
SQLFetch( ... );

Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question