Hello,
Now I am stuck with getting const char* array from function to main.
main:
const char* values[3];
strings_to_array();
Type: Posts; User: nime
Hello,
Now I am stuck with getting const char* array from function to main.
main:
const char* values[3];
strings_to_array();
Interesting situation!
DBgetvalue(result, 0, 0); is actually a string (one char) but that string is number 1-4.
So if I set retval to "-1" then I haven't check if function return's null.
Instead I...
Mr. Lnx, 0 is default value which will be returned if no data from database.
Should I set it to NULL insead, or what?
Yes, yes, thank you.
char* retval = 0;
I declared retval as int instead of char* (because of copying from other function).
Now this work as expected.
I am still suffering with pointers.
// main
int index = 50;
char* flagx = mytable_get_flag(conn, index);
printf("flag=%s\n", flagx);
Thanks a lot, now i understand a warning.
int myfunc(DBconn* conn, int *rmin, int *rmax)
{
int retval = -1;
if ((dbtableexists(conn, mytable)) > 0)
{
This is very shortened code of my fumction:
int myfunc(DBconn* conn, int rmin, int rmax)
{
rmin = 0;
rmax = 0;
int retval = -1;
I see, thanks migf1. I thougt it's a standard function since I have it without additional upgrading of my C.
When we are here, if I have to allocate and clean variable in main program how nobody to mention "strdup" command?
Isn't it more elegant than do it by hand?
Barney, I do some checks at startup so I assume that then things will work. If error happens it it still better than "hidden" error.
Regarding endians and alignment, is it possible to do something...
Barney, portable to what. This works in linux same as in windows.
Null pointer is possible if caller ask for a record which is higher than last existed.
Maybe I have to declare char* k = 0; at top...
I didn't want to make so wide discussion on relatively simple question and because of that I present a simple example.
If is really needed I can describe real situation more precisely just to let...
@Andi, I already get satisfied answer in first two replies to my question what mean that question is formed correctly.
I practic situation my char array (temp) is readen from binary file and...
Because it is part of complex project what mean not suitable to post here as example.
Andi, because I have concrete situation behind this simplified example which requires to pass a pointer.
@hk_mp5kpdw
Like that?
strcpy(f, getstatus(sel));
if (f[0] == '0' || f[0] == ' ' || f[0] == '\0')
@jimblumberg, this don't work.
@rcgldr
I see about that problems.
As for now I can get data to main program like this:
char f[2] = {0};
strcpy(f, getstatus(5));
...
Hello,
I would like to clear some things regarding transfer a value by pointer among porcedures in project.
Situation:
In header I have declaration of function prototype:
char*...
Sorry grumpy, I was not understand what you suggest.
Why is in this case using of static int inside this function bad?
@rcgldr
What a nice idea. It works wery well, thank you!
Hi rcgldr,
Yes, I'm using gcc. That way programs are highly portable to linux if I don't use win api, winforms and so...
What I don't understand is that some folders have one subdir and some may...
However, it would be interesting to know under...
if(S_ISDIR(stFileInfo.st_mode))
{...
how deep we are from initial directory, like 1, 2 or more subdirectory level....
Thank's for replies but since noone point to right direction, I have to solve a problem by myself.
This is very simple but efficient and potrable code for recursive directory scanning for c files...
Hello,
I do recursive dir scanning for .c files in tree on linux but that one don't work on windows because of that:
if (entry->d_type & DT_DIR)
So I have to change code and now I have...
FINALY!
Thank you Andrew!
For this purpose I made LEFT, MID and RIGHT functions so I can work like in VB.
And here are how program looks now.
int arrayOffset;
arrayOffset = (found -...