Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to return these variables

Posted on 1999-01-20
2
Medium Priority
?
166 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 120 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files 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.

722 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