473,385 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

best way to declare struct to be used in other c and c++ files

Hello all,

I am wondering what is the best way to declare a struct to be used in
other c and c++ files. Such as for a C API that will be used by
others.

1. Declaring the typedef and the struct in the header file and
including this file in all source files that need it? For example:

mystruct.h

typedef mystruct mystruct_t;

struct mystruct {
int x;
char c;
};

-OR-
2. Declaring the typedef in a header file and declaring the struct in
the .c file ( I am not certain that this will work). For example:

mystruct.h

typedef mystruct mystruct_t;
mystruct.c

#include "mystruct.h"

struct mystruct {
int x;
char c;
};

......(other code using the structure)

-OR-

3. Other methods??

Thanks in advance for your help,
Tammy


Sep 6 '08 #1
10 2429
Tammy wrote:
Hello all,

I am wondering what is the best way to declare a struct to be used in
other c and c++ files. Such as for a C API that will be used by
others.

1. Declaring the typedef and the struct in the header file and
including this file in all source files that need it?
I define the typedef in the header file
and include this file in all source files that need it.

http://www.mindspring.com/~pfilandr/...ver/e_driver.h

#define E_TYPE struct {char array[40]; d_type data;} e_type
#define D_TYPE long double d_type
typedef D_TYPE;
typedef E_TYPE;

http://www.mindspring.com/~pfilandr/C/e_driver/

--
pete
Sep 6 '08 #2
Tammy wrote:
Hello all,

I am wondering what is the best way to declare a struct to be used in
other c and c++ files. Such as for a C API that will be used by
others.

1. Declaring the typedef and the struct in the header file and
including this file in all source files that need it? For example:

mystruct.h

typedef mystruct mystruct_t;

struct mystruct {
int x;
char c;
};
This is the normal way for a public structure declaration, with the
addition of a conditionally compiled extern "C" wrapper for the benefit
of C++ files that include the header.
-OR-
2. Declaring the typedef in a header file and declaring the struct in
the .c file ( I am not certain that this will work). For example:

mystruct.h

typedef mystruct mystruct_t;
mystruct.c

#include "mystruct.h"

struct mystruct {
int x;
char c;
};
If you want the details of mystruct to remain hidden, this is also
common practice.

--
Ian Collins.
Sep 6 '08 #3
Tammy <Ta*************@gmail.comwrites:
I am wondering what is the best way to declare a struct to be used in
other c and c++ files. Such as for a C API that will be used by
others.

1. Declaring the typedef and the struct in the header file and
including this file in all source files that need it? For example:

mystruct.h

typedef mystruct mystruct_t;

struct mystruct {
int x;
char c;
};
That needs to be "typedef struct mystruct mystruct_t;".
-OR-
2. Declaring the typedef in a header file and declaring the struct in
the .c file ( I am not certain that this will work). For example:

mystruct.h

typedef mystruct mystruct_t;
mystruct.c

#include "mystruct.h"

struct mystruct {
int x;
char c;
};

.....(other code using the structure)
[...]

It depends on whether the client code needs to see the members and/or
declare objects of the type.

With the second approach struct mystruct, and therefore mystruct_t, is
an incomplete type as far as anything with a #include "mystruct.h" is
concerned. That means that client code can declare and manipulate
pointers to the type, but it can't declare objects of the type or
refer to its members.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Sep 6 '08 #4
pete <pf*****@mindspring.comwrites:
Tammy wrote:
>Hello all,
I am wondering what is the best way to declare a struct to be used in
other c and c++ files. Such as for a C API that will be used by
others.
1. Declaring the typedef and the struct in the header file and
including this file in all source files that need it?

I define the typedef in the header file
and include this file in all source files that need it.

http://www.mindspring.com/~pfilandr/...ver/e_driver.h

#define E_TYPE struct {char array[40]; d_type data;} e_type
#define D_TYPE long double d_type
typedef D_TYPE;
typedef E_TYPE;

http://www.mindspring.com/~pfilandr/C/e_driver/
That's a very odd use of macros; I find it extremely counterintuitive.

Looking at the web page, it makes *some* sense in context. You have
(I'm abbreviating this):

#define STRUCTURES 0 /* 0 or 1, This is the line to change */

#if STRUCTURES == 0 /* Not this one */

#define E_TYPE long unsigned e_type
#define D_TYPE long unsigned d_type

#else

#define E_TYPE struct {char array[40]; d_type data;} e_type
#define D_TYPE long double d_type

#endif

typedef D_TYPE;
typedef E_TYPE;

I'm sure there's some good reason to conditionally define E_TYPE and
D_TYPE either as unsigned long or as a struct and a long double; I
haven't read enough of the code to understand what that reason might
be. But I definitely wouldn't write it that way. I'd probably write
something more like this:

#undef STRUCTURES /* defined or undefined

#ifdef STRUCTURES

typedef long double d_type;
typedef struct {char array[40]; d_type data;} e_type;

#else

typedef unsigned long d_type;
typedef unsigned long e_type;

#endif

In any case, your code sample illustrates the use of the preprocessor
to conditionally define types in one of two different ways, which
isn't what the OP was asking about.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Sep 6 '08 #5
Keith Thompson wrote:
pete <pf*****@mindspring.comwrites:
>Tammy wrote:
>>Hello all,
I am wondering what is the best way to declare a struct to be used in
other c and c++ files. Such as for a C API that will be used by
others.
1. Declaring the typedef and the struct in the header file and
including this file in all source files that need it?
I define the typedef in the header file
and include this file in all source files that need it.

http://www.mindspring.com/~pfilandr/...ver/e_driver.h

#define E_TYPE struct {char array[40]; d_type data;} e_type
#define D_TYPE long double d_type
typedef D_TYPE;
typedef E_TYPE;

http://www.mindspring.com/~pfilandr/C/e_driver/

That's a very odd use of macros; I find it extremely counterintuitive.

Looking at the web page, it makes *some* sense in context. You have
(I'm abbreviating this):

#define STRUCTURES 0 /* 0 or 1, This is the line to change */

#if STRUCTURES == 0 /* Not this one */

#define E_TYPE long unsigned e_type
#define D_TYPE long unsigned d_type

#else

#define E_TYPE struct {char array[40]; d_type data;} e_type
#define D_TYPE long double d_type

#endif

typedef D_TYPE;
typedef E_TYPE;

I'm sure there's some good reason to conditionally define E_TYPE and
D_TYPE either as unsigned long or as a struct and a long double;
I prefer to have the readily changeable parts of the program,
be macros.
The program also prints out the stringized macros.

The proper use of of the e_type interface,
is to define at least these three macros in a header file,
(there may be other macros depending on the sort algorithm)
for sorting functions which can then be used to sort
arrays of elements of any type, including arrays of arrays:

#define E_TYPE
#define MOV(A, B)
#define GT(A, B)

For example, I was looking at:
http://www.pobox.com/~qed/sort.html
which redirected me to
http://www.azillionmonkeys.com/qed/sort.html
and I downloaded the program at this link:
http://www.azillionmonkeys.com/qed/sorttest.c

and since I like to race sorting functions,
I changed the name of the program to pq_test
and replaced the definition of main with this:

#include "test_sort.h"

#define str(s) # s
#define xstr(s) str(s)

int main (void)
{
int seed = 0;
double r0, r1, r2, r3, r4, r5, r6, r7;

/* Warm up the cache */
{
int i;
for (i = 0; i < NUM_ITEMS; i++) numbers[i] = i;
heapSort (numbers, NUM_ITEMS);
}

r0 = timetest (seed, heapSort);
r1 = timetest (seed, quickSort);
r2 = timetest (seed, mergeSort);
r3 = NUM_ITEMS 600 ? 0 : timetest (seed, insertSort);
r4 = timetest (seed, hsortmwrapper);
r5 = timetest (seed, pqsortwrapper);
r6 = timetest (seed, stablewrapper);
r7 = NUM_ITEMS 600 ? 0 : timetest (seed, sisortwrapper);

puts("/* BEGIN pq_test.c output */\n");
puts("#define NUM_ITEMS " xstr(NUM_ITEMS) "\n");
printf (" heapsort: %.3f\n", r0);
printf (" quicksort: %.3f\n", r1);
printf (" mergesort: %.3f\n", r2);
printf ("insertsort: %.3f\n", r3);
putchar('\n');
printf (" hsortm: %.3f\n", r4);
printf (" pqsort: %.3f\n", r5);
printf (" stable: %.3f\n", r6);
printf (" sisort: %.3f\n", r7);
puts("\n/* END pq_test.c output */");

return 0;
}

Then I got these results:

/* BEGIN pq_test.c output */

#define NUM_ITEMS 6000

heapsort: 4.594
quicksort: 3.375
mergesort: 4.531
insertsort: 0.000

hsortm: 4.296
pqsort: 2.562
stable: 3.640
sisort: 0.000

/* END pq_test.c output */

Then I changed NUM_ITEMS to 600 and got these results:

/* BEGIN pq_test.c output */

#define NUM_ITEMS 600

heapsort: 0.375
quicksort: 0.265
mergesort: 0.359
insertsort: 2.406

hsortm: 0.344
pqsort: 0.203
stable: 0.281
sisort: 1.125

/* END pq_test.c output */

I also wrote 4 files to complete the program:
test_sort.h
test_sort.c
pqsort.h
pqsort.c

The point of doing it that way, is that the file,
pqsort.c, can be used as is, to sort arrays of any type,
without changing even a single byte.

The files look like this:

/* BEGIN test_sort.h */

#ifndef H_TEST_SORT_H
#define H_TEST_SORT_H

void hsortmwrapper(int numbers[], int qty);
void pqsortwrapper(int numbers[], int qty);
void stablewrapper(int numbers[], int qty);
void sisortwrapper(int numbers[], int qty);

#endif

/* END test_sort.h */
/* BEGIN test_sort.c */

#include <assert.h>

#include "test_sort.h"
#include "pqsort.h"

void hsortmwrapper(int numbers[], int qty)
{
hsortm(numbers, qty);
}

void pqsortwrapper(int numbers[], int qty)
{
assert(SMALL_PARTITION >= 4);
pqsort(numbers, qty);
}

void stablewrapper(int numbers[], int qty)
{
assert(SMALL_MERGE >= 1);
stable(numbers, qty);
}

void sisortwrapper(int numbers[], int qty)
{
sisort(numbers, qty);
}

/* END test_sort.c */
/* BEGIN pqsort.h */

#ifndef H_PQSORT_H
#define H_PQSORT_H

#include <stddef.h>

#define E_TYPE int e_type
#define MOV(A, B) ((void)(*(A) = *(B)))
#define GT(A, B) (*(A) *(B))
#define SMALL_PARTITION 24
#define SMALL_MERGE 32

typedef E_TYPE;
/*
** (hsortm) is a double siftdown, casual heapsort.
*/
void hsortm(e_type *array, size_t nmemb);
/*
** (pqsort) is an introspective, median of three, quicksort.
*/
void pqsort(e_type *array, size_t nmemb);
/*
** (stable) is a stable merge sort / insertion sort.
*/
void stable(e_type *array, size_t nmemb);
/*
** (sisort) is a stable insertion sort.
*/
void sisort(e_type *array, size_t nmemb);

#endif

/* END pqsort.h */
/* BEGIN pqsort.c */

#include <stdlib.h>

#include "pqsort.h"

#define SWAP(A, B, T) \
(MOV((T), (A)), MOV((A), (B)), MOV((B), (T)))
#define SORT_3(A, B, C, T) \
if (GT((A), (B))) { \
MOV((T), (A)); \
if (GT((C), (B))) { \
MOV((A), (B)); \
if (GT((T), (C))) { \
MOV((B), (C)); \
MOV((C), (T)); \
} else { \
MOV((B), (T)); \
} \
} else { \
MOV((A), (C)); \
MOV((C), (T)); \
} \
} else { \
if (GT((B), (C))) { \
MOV((T), (B)); \
if (GT((A), (C))) { \
MOV((B), (A)); \
MOV((A), (C)); \
} else { \
MOV((B), (C)); \
} \
MOV((C), (T)); \
} \
}
#define SIFTDOWNM(P) \
{ \
parent = (P); \
child = parent * 2; \
MOV(&temp, array + parent); \
while (nmemb - parent parent) { \
if (GT(array + child + 1, array + child)) { \
++child; \
} \
if (GT(array + child, &temp)) { \
MOV(array + parent, array + child); \
parent = child; \
child *= 2; \
} else { \
break; \
} \
} \
if (nmemb == child && GT(array + child, &temp)) { \
MOV(array + parent, array + child); \
parent = child; \
} \
MOV(array + parent, &temp); \
}

static void pqloop(e_type *array, size_t nmemb, size_t d);
static void merge(e_type *array, size_t nmemb, e_type *buff);

void hsortm(e_type *array, size_t nmemb)
{
size_t p, child, parent;
e_type temp;

if (nmemb 1) {
p = --nmemb / 2;
do {
SIFTDOWNM(p);
} while (p-- != 0);
SWAP(array, array + nmemb, &temp);
while (--nmemb != 0) {
SIFTDOWNM(0);
SWAP(array, array + nmemb, &temp);
}
}
}

void pqsort(e_type *array, size_t nmemb)
{
size_t d, n;

d = 2;
for (n = nmemb / 4; n != 0; n /= 2) {
++d;
}
pqloop(array, nmemb, 2 * d);
}

void stable(e_type *array, size_t nmemb)
{
e_type *buff = malloc(nmemb / 2 * sizeof *buff);

if (buff != NULL) {
merge(array, nmemb, buff);
free(buff);
} else {
sisort(array, nmemb);
}
}

void sisort(e_type *array, size_t nmemb)
{
e_type *base, *low, *high, temp;

if (nmemb-- 1) {
base = array;
do {
low = array++;
if (GT(low, array)) {
high = array;
MOV(&temp, high);
do {
MOV(high, low);
if (--high == base) {
break;
}
--low;
} while (GT(low, &temp));
MOV(high, &temp);
}
} while (--nmemb != 0);
}
}

static void pqloop(e_type *array, size_t nmemb, size_t d)
{
e_type *i, *j, temp;

while (nmemb SMALL_PARTITION) {
if (!d--) {
hsortm(array, nmemb);
return;
}
i = 1 + array;
j = --nmemb + array;
SORT_3(j, array, i, &temp);
do {
SWAP(j, i, &temp);
do {
++i;
} while (GT(array, i));
do {
--j;
} while (GT(j, array));
} while (j i);
SWAP(array, j, &temp);
pqloop(j + 1, nmemb + array - j, d);
nmemb = j - array;
}
sisort(array, nmemb);
}

static void merge(e_type *array, size_t nmemb, e_type *buff)
{
if (nmemb SMALL_MERGE) {
e_type *mid_ptr;
size_t const half = nmemb / 2;
e_type *const after_buff = buff + half;
e_type *const middle = array + half;
e_type *const after_array = array + nmemb;

merge(middle, nmemb - half, buff);
merge(array, half, buff);
do {
if (GT(array, middle)) {
mid_ptr = middle;
buff = after_buff;
do {
--buff;
--mid_ptr;
MOV(buff, mid_ptr);
} while (array != mid_ptr);
MOV(array, middle);
mid_ptr = middle + 1;
while (middle != ++array) {
if (GT(buff, mid_ptr)) {
MOV(array, mid_ptr);
++mid_ptr;
} else {
MOV(array, buff);
++buff;
}
}
while (after_buff != buff) {
if (after_array != mid_ptr) {
if (GT(buff, mid_ptr)) {
MOV(array, mid_ptr);
++mid_ptr;
} else {
MOV(array, buff);
++buff;
}
++array;
} else {
do {
MOV(array, buff);
++array;
++buff;
} while (after_buff != buff);
break;
}
}
break;
} else {
++array;
}
} while (middle != array);
} else {
sisort(array, nmemb);
}
}

/* END pqsort.c */
--
pete
Sep 6 '08 #6
ac
On Sat, 06 Sep 2008 07:50:47 +0100, pete <pf*****@mindspring.comwrote:
I prefer to have the readily changeable parts of the program,
be macros.
The program also prints out the stringized macros.

The proper use of of the e_type interface,
is to define at least these three macros in a header file,
(there may be other macros depending on the sort algorithm)
for sorting functions which can then be used to sort
arrays of elements of any type, including arrays of arrays:

#define E_TYPE
#define MOV(A, B)
#define GT(A, B)

For example, I was looking at:
http://www.pobox.com/~qed/sort.html
which redirected me to
http://www.azillionmonkeys.com/qed/sort.html
and I downloaded the program at this link:
http://www.azillionmonkeys.com/qed/sorttest.c

and since I like to race sorting functions,
I changed the name of the program to pq_test
and replaced the definition of main with this:
Maybe a potential problem with this E_TYPE is we can only define one
etype_t in one C source file, which means we cannot sort an integer array
and a double array in the same C source file. Is that true? I think a
better way to achieve generic types is this example, using token
concatenation:

http://www.freewebs.com/attractivechaos/ksort.h.html
http://www.freewebs.com/attractivech...rt_test.c.html

No function calls are made for comparisons, either.

BTW, it seems that you have implemented really efficient sorting
functions! How is it compared to STL sort?

Thanks,

-ac
Sep 6 '08 #7
ac wrote:
On Sat, 06 Sep 2008 07:50:47 +0100, pete <pf*****@mindspring.comwrote:
>I prefer to have the readily changeable parts of the program,
be macros.
The program also prints out the stringized macros.

The proper use of of the e_type interface,
is to define at least these three macros in a header file,
(there may be other macros depending on the sort algorithm)
for sorting functions which can then be used to sort
arrays of elements of any type, including arrays of arrays:

#define E_TYPE
#define MOV(A, B)
#define GT(A, B)

For example, I was looking at:
http://www.pobox.com/~qed/sort.html
which redirected me to
http://www.azillionmonkeys.com/qed/sort.html
and I downloaded the program at this link:
http://www.azillionmonkeys.com/qed/sorttest.c

and since I like to race sorting functions,
I changed the name of the program to pq_test
and replaced the definition of main with this:

Maybe a potential problem with this E_TYPE is we can only define one
etype_t
I've heard that etype_t is reserved under POSIX rules,
which is why I write e_type.
in one C source file, which means we cannot sort an integer
array and a double array in the same C source file. Is that true?
Yes.
I think a better way to achieve generic types is this example,
using token concatenation:

http://www.freewebs.com/attractivechaos/ksort.h.html
http://www.freewebs.com/attractivech...rt_test.c.html

No function calls are made for comparisons, either.
Thank you.
That's very interesting to me.
I have no experience with ##.
Maybe it's about time for me to become more familiar with it.
BTW, it seems that you have implemented really efficient sorting
functions!
Thank you. It's a hobby of mine.
How is it compared to STL sort?
It's actually Dann Corbit's C version of STL sort.
It's a smidgeon slower.

--
pete
Sep 7 '08 #8
ac
On Sun, 07 Sep 2008 03:20:21 +0100, pete <pf*****@mindspring.comwrote:
That's very interesting to me.
I have no experience with ##.
Maybe it's about time for me to become more familiar with it.
If you are interested in this method, you may also have a look at this
header file:

http://www.freebsd.org/cgi/cvsweb.cg...sys/sys/tree.h

This file is part of freebsd. It implements a splay tree and a rb tree,
allowing for generic types.

-ac
Sep 7 '08 #9
pete <pfil...@mindspring.comwrote:
...The proper use of of the e_type interface,
is to define at least these three macros in a header file,
(there may be other macros depending on the sort algorithm)
for sorting functions which can then be used to sort
arrays of elements of any type, including arrays of arrays:

#define E_TYPE
#define MOV(A, B)
#define GT(A, B)
I prefer to make the configurable components of the sort
template functions as macro parameters. [The following is
just proof of concept. File break up requires (re)insertion
of include guards and other details.]
%type sort.c
/* --------- */
/* pp_util.h */
/* --------- */
#define pp_cat(a, b) a ## b
#define pp_concat(a, b) pp_cat(a, b)

#define pp_t(T) pp_concat(T, _t)
typedef int int_t; /* and the rest */

#define pp_lt(a, b) ((a) < (b))
#define pp_assign(a, b) ((a) = (b))
#define pp_memcpy(a, b) memcpy(a, b, sizeof(a))
/* --------- */
/* pp_sort.h */
/* --------- */

/* #include "pp_util.h" */
#include <stddef.h>

#define pp_sort(T, a, n) \
pp_concat(sort_, T)(a, n)

#define pp_decl_sort(T) \
void pp_concat(sort_, T)(pp_t(T) *, size_t)

/* trivial for sake of demo */
#define pp_defn_sort(T, lt_pp, assign_pp) \
void pp_concat(sort_, T)( pp_t(T) *a, \
size_t n ) \
{ \
size_t i, j, k; \
pp_t(T) t; \
\
for (i = 0; i < n - 1; i++) \
{ \
for (k = i, j = i + 1; j < n; j++) \
if (lt_pp(a[j], a[i])) \
k = j; \
\
if (k != i) \
{ \
assign_pp(t, a[i]); \
assign_pp(a[i], a[k]); \
assign_pp(a[k], t ); \
} \
} \
}

pp_decl_sort(int); /* built-ins */
/* ----------- */
/* gauss_int.h */
/* ----------- */

typedef int gauss_int_t[2];
pp_decl_sort(gauss_int);
/* ------ */
/* main.c */
/* ------ */

/* #include "gauss_int.h" */
/* #include "pp_sort.h" */
#include <stdio.h>

#define countof(x) \
((size_t) (sizeof(x)/sizeof*(x)))

int main(void)
{
int ai[] = { 2, -4, 8, -16 };
gauss_int_t gi[] = { { 2, -4},
{ -8, 16 },
{32, -64},
{-128, 256} };
size_t i;

/* Integers */
for (i = 0; i < countof(ai); i++)
printf(" %d", ai[i]);
puts("");

sort_int(ai, countof(ai));

for (i = 0; i < countof(ai); i++)
printf(" %d", ai[i]);
puts("\n");

/* Gaussian Integers */
for (i = 0; i < countof(ai); i++)
printf(" (%d, %d)", gi[i][0], gi[i][1]);
puts("");

sort_gauss_int(gi, countof(gi));

for (i = 0; i < countof(ai); i++)
printf(" (%d, %d)", gi[i][0], gi[i][1]);
puts("");

return 0;
}
/* ------ */
/* sort.c */
/* ------ */

/* #include "pp_sort.h" */

pp_defn_sort(int, pp_lt, pp_assign)
/* ----------- */
/* gauss_int.c */
/* ----------- */

/* #include "pp_util.h" */
/* #include "pp_sort.h" */
#include <string.h>

#define pp_gauss_lt(a, b) \
( pp_lt( (a)[0], (b)[0] ) ? 1 \
: pp_lt( (b)[0], (a)[0] ) ? 0 \
: pp_lt( (a)[1], (b)[1] ) )

pp_defn_sort(gauss_int, pp_gauss_lt, pp_memcpy)

% acc sort.c

% a
2 -4 8 -16
-16 -4 2 8

(2, -4) (-8, 16) (32, -64) (-128, 256)
(-128, 256) (-8, 16) (2, -4) (32, -64)

%

--
Peter
Sep 8 '08 #10
Peter Nilsson wrote:
pete <pfil...@mindspring.comwrote:
>...The proper use of of the e_type interface,
is to define at least these three macros in a header file,
(there may be other macros depending on the sort algorithm)
for sorting functions which can then be used to sort
arrays of elements of any type, including arrays of arrays:

#define E_TYPE
#define MOV(A, B)
#define GT(A, B)

I prefer to make the configurable components of the sort
template functions as macro parameters. [The following is
just proof of concept. File break up requires (re)insertion
of include guards and other details.]
%type sort.c
/* --------- */
/* pp_util.h */
/* --------- */
#define pp_cat(a, b) a ## b
#define pp_concat(a, b) pp_cat(a, b)

#define pp_t(T) pp_concat(T, _t)
typedef int int_t; /* and the rest */

#define pp_lt(a, b) ((a) < (b))
#define pp_assign(a, b) ((a) = (b))
#define pp_memcpy(a, b) memcpy(a, b, sizeof(a))
Thank you.
I'll give it a good look.
--
pete
Sep 8 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Geetesh | last post by:
Recently i saw a code in which there was a structer defination similar as bellow: struct foo { int dummy1; int dummy2; int last }; In application the above array is always allocated at...
1
by: mrhicks | last post by:
Hello all, I am trying to keep my coding easy for everyone to use. I have some ARINC data that need to go out which 12 Bytes long. The first byte is the command word, the next 10 bytes represent...
15
by: Geoff Cox | last post by:
Hello, Can I separately declare and initialize a string array? How and where would I do it in the code below? It was created using Visual C++ 2005 Express Beta 2 ... In C# I would have ...
14
by: Jon Rea | last post by:
I am currently cleaning up an application which was origainlly hashed together with speed of coding in mind and therefore contains quite a few "hacky" shortcuts. As part of this "revamping"...
5
by: sherifffruitfly | last post by:
Hi, I'm just learning cpp, and the exercise I'm working on is basically as follows: 1) Create a struct type with 4 members (char, char, char, int). 2) Create an array of, say 3 instances of...
6
by: Amit_Basnak | last post by:
Dear Friends I have two structures as below typedef struct { long_int length; char data; } CI_STRUCT_DATA; typedef CI_STRUCT_DATA *ptr_CiStructData;
27
by: arkmancn | last post by:
Any comments? thanks. Jim
2
by: beet | last post by:
Hi all, I tried to declare a c++ struct like following in a header file; I want to include this header file in other files to create and access this struct. ------ 1 #ifndef _SEARCHDATA_H_...
2
by: stephen.diverdi | last post by:
I have a question about what's the best way to handle something in C++ without a lot of redundant code and void*s because I don't seem to be able to avoid them both. I've run into it before and...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.