Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7774633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:25:40+00:00 2026-06-01T17:25:40+00:00

I’m trying adapt the example code shown in the Array Interface Example section here,

  • 0

I’m trying adapt the example code shown in the “Array Interface Example” section here,

http://orclib.sourceforge.net/doc/html/group_g_bind.html

where they place an array of strings, tab_str, into OCI_BindArrayOfStrings using:

char tab_str[1000][21];
...
OCI_BindArrayOfStrings(st, ":s", (char*) tab_str, 20, 0);

The problem is, the above example knows the array length at compile time, whereas I have to download this length from a database when the program is run. So I’d like to create an array of strings, called my_tab_str and place it in the following line of code:

OCI_BindArrayOfStrings(st, ":s", (char*) my_tab_str, 20, 0);

My question is how to set up my_tab_str? Here’s my code (compiled using gcc -std=C89):

int i, arraysize;
char person_name[20] = "";
char * my_tab_str;
...
strncpy(person_name, "John Smith", 19);
arraysize = <this value is downloaded from database>;
...
my_tab_str = malloc( arraysize * sizeof(char) * (strlen(person_name)+1) );
for(i=0;i<arraysize;i++) {
    strncpy( my_tab_str[i], person_name, strlen(person_name) );
}

The goal is to place “John Smith” (e.g 10 bytes) plus a null termination character (which I think is automatically added by the compiler) into each element of the array of strings my_tab_str.

I’m getting the compile warning: warning: passing argument 1 of 'strncpy' makes pointer from integer without a cast
/usr/include/string.h:131: note: expected 'char * __restrict__' but argument is of type 'char'

Note that the function OCI_BindArrayOfStrings is described here:

http://orclib.sourceforge.net/doc/html/group_g_bind.html#ga502cd4785691b17955f5d99276e48884

and expects an array of string as an argument. See the example code at the first link above for an example implementation.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T17:25:41+00:00Added an answer on June 1, 2026 at 5:25 pm

    It’s not entirely clear from your post what that function expects as an argument. I’m going to assume it’s a char **.

    In that case, you need to do something like this:

    // Allocate an array of pointers
    char **my_tab_str = calloc(arraysize, sizeof(*my_tab_str));
    
    // Allocate room for each string in turn
    for (int i = 0; i < arraysize; i++) {
        // person_name comes from somewhere
        const int len = strlen(person_name);
        my_tab_str[i] = calloc(len+1, sizeof(*my_tab_str[i]));
        strncpy(my_tab_str[i], person_name, len);
    }
    

    UPDATE

    Ok, so it looks like that function takes a char * which points to a contiguous 1D array of all the strings concatenated, along with the number of strings, and the length of each string. In which case, you’ll need to do something like this:

    const int len = strlen(person_name);
    
    // Big 1D array
    char *my_tab_str = calloc(arraysize*(len+1), sizeof(*my_tab_str));
    
    // Put each string into the 1D array, at regular intervals
    for (int i = 0; i < arraysize; i++) {
        strncpy(&my_tab_str[i*(len+1)], person_name, len);
    }
    

    This is just a guess though, because that function really isn’t well-documented.

    Obviously, you will also need some cleanup code at some point that carefully frees everything.

    And if you want to be really careful, you should add error-handling code that checks the result of each calloc for NULL, but that would clutter the example, so I’ve omitted it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
i got an object with contents of html markup in it, for example: string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.