Solved

How to return these variables

Posted on 1999-01-20
2
157 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
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now