473,708 Members | 2,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can any one help me find out what was the problem in this small

It always dumped when I tried to run it... But it compiles OK. What I
want to do is to do a test:
Read information from a .dat file and then write it to another file.
The original DAT file is like this : (very simple......... .)
010001010110001 101010101010101 010101010101


#include<stdio. h>
#include<stdlib .h>
#include<string .h>

typedef struct _HEADER {

int num1;
int num2;
int num3;
int num4;

}HEADER;

int i;

int x;
int y;
int z;

void readheader(HEAD ER *,FILE *);
void writeheader(HEA DER *,FILE *);
main()

{

FILE *fp1;
FILE *fp2;

HEADER header;
short ***datatable;

fp1=fopen("g.da t","rb+");
fp2=fopen("newd ata.dat","wb+") ;
readheader(&hea der,fp1);
for(x=0; x<2 ;x++){
for (y=0; y<3; y++){
for(z=0; z<4; z++){
fread(&datatabl e[x][y][z],sizeof(short), 24,fp1);
fclose(fp1);
}
}
}

writeheader(&he ader,fp2);

for(x=0; x<2 ;x++){
for (y=0; y<3; y++){
for(z=0; z<4; z++){
fwrite(&datatab le[x][y][z],sizeof(short), 24,fp2);
fclose(fp2);
}
}
}

}

void readheader(HEAD ER *header,FILE *fp1)
{
fread(&(header->num1),sizeof(i nt),1,fp1);
fread(&(header->num2),sizeof(i nt),1,fp1);
fread(&(header->num3),sizeof(i nt),1,fp1);
fread(&(header->num4),sizeof(i nt),1,fp1);
}

void writeheader(HEA DER *header,FILE *fp2)
{
fwrite(&(header->num1),sizeof(i nt),1,fp2);
fwrite(&(header->num2),sizeof(i nt),1,fp2);
fwrite(&(header->num3),sizeof(i nt),1,fp2);
fwrite(&(header->num4),sizeof(i nt),1,fp2);
}
Jul 20 '08 #1
9 1925
xiao wrote:
It always dumped when I tried to run it... But it compiles OK.
[...]
short ***datatable;
[no allocation anywhere of space for datatable (or *datatable or
**datatable) to point to, and then]
for(x=0; x<2 ;x++){
for (y=0; y<3; y++){
for(z=0; z<4; z++){
fread(&datatabl e[x][y][z],sizeof(short), 24,fp1);
fclose(fp1);
}
And you actually wonder why you get segfault?
Jul 20 '08 #2
On 20 Jul, 03:57, xiao <littledd...@gm ail.comwrote:
It always dumped when I tried to run it... But it compiles OK. *
<snip>
>
int i;
Why would you make your loop variables global? This
is a horrible decision.
>
main()
This declaration has been obsolete for a *long* time.
"int main(void)" or "int main( int argc, char **argv)".

>
fp1=fopen("g.da t","rb+");
fp2=fopen("newd ata.dat","wb+") ;
You MUST check for errors here. If you wish to keep
the code simple for the sake of example, then just
write "fp1 = Fopen(..." and mention that Fopen s
a wrapper that checks for an error. Or, if you
prefer, don't mention that it is a wrapper and
let the reader make that assumption. But do not
ever fail to check the return value of a call
to fopen().

>
fread(&datatabl e[x][y][z],sizeof(short), 24,fp1);

Since no memory has been allocated for datatable,
or datatable[x], or datatable[x][y],
this is very likely to cause an error. (You should
either malloc space for each, or simply declare
datatable as "short datatable[2][3][4]"). However,
it is not clear why you wish to read 24 shorts
24 times. If you do the loop, then just read one
value at a time. If you read 24 values, then don't
do the loop.

Jul 20 '08 #3
On Sat, 19 Jul 2008 19:57:59 -0700 (PDT), xiao <li*********@gm ail.com>
wrote:
>It always dumped when I tried to run it... But it compiles OK. What I
want to do is to do a test:
Read information from a .dat file and then write it to another file.
The original DAT file is like this : (very simple......... .)
01000101011000 110101010101010 1010101010101


#include<stdio .h>
#include<stdli b.h>
#include<strin g.h>

typedef struct _HEADER {

int num1;
int num2;
int num3;
int num4;

}HEADER;

int i;

int x;
int y;
int z;

void readheader(HEAD ER *,FILE *);
void writeheader(HEA DER *,FILE *);
main()

{

FILE *fp1;
FILE *fp2;

HEADER header;
short ***datatable;
Where does this pointer ever get assigned the address of memory you
own?
>
fp1=fopen("g.d at","rb+");
fp2=fopen("new data.dat","wb+" );
readheader(&he ader,fp1);
for(x=0; x<2 ;x++){
for (y=0; y<3; y++){
for(z=0; z<4; z++){
fread(&datatab le[x][y][z],sizeof(short), 24,fp1);
After you solve the problem of where datatable points to, this will
lead to a buffer overflow and undefined behavior. If datatable is
intended to be a 2 x 3 x 4 array of short, then there are only 24
short in the array. If fread is going to read all 24, is should do it
only once and it better start reading from the beginning.
fclose(fp1);
}
}
}

writeheader(&h eader,fp2);

for(x=0; x<2 ;x++){
for (y=0; y<3; y++){
for(z=0; z<4; z++){
fwrite(&datata ble[x][y][z],sizeof(short), 24,fp2);
fclose(fp2);
}
}
}

}

void readheader(HEAD ER *header,FILE *fp1)
{
fread(&(head er->num1),sizeof(i nt),1,fp1);
fread(&(head er->num2),sizeof(i nt),1,fp1);
fread(&(head er->num3),sizeof(i nt),1,fp1);
fread(&(head er->num4),sizeof(i nt),1,fp1);
}

void writeheader(HEA DER *header,FILE *fp2)
{
fwrite(&(heade r->num1),sizeof(i nt),1,fp2);
fwrite(&(heade r->num2),sizeof(i nt),1,fp2);
fwrite(&(heade r->num3),sizeof(i nt),1,fp2);
fwrite(&(heade r->num4),sizeof(i nt),1,fp2);
}

Remove del for email
Jul 20 '08 #4
On Jul 20, 2:04 am, Barry Schwarz <schwa...@dqel. comwrote:
On Sat, 19 Jul 2008 19:57:59 -0700 (PDT), xiao <littledd...@gm ail.com>
wrote:
It always dumped when I tried to run it... But it compiles OK. What I
want to do is to do a test:
Read information from a .dat file and then write it to another file.
The original DAT file is like this : (very simple......... .)
010001010110001 101010101010101 010101010101
#include<stdio. h>
#include<stdlib .h>
#include<string .h>
typedef struct _HEADER {
int num1;
int num2;
int num3;
int num4;
}HEADER;
int i;
int x;
int y;
int z;
void readheader(HEAD ER *,FILE *);
void writeheader(HEA DER *,FILE *);
main()
{
FILE *fp1;
FILE *fp2;
HEADER header;
short ***datatable;

Where does this pointer ever get assigned the address of memory you
own?
fp1=fopen("g.da t","rb+");
fp2=fopen("newd ata.dat","wb+") ;
readheader(&hea der,fp1);
for(x=0; x<2 ;x++){
for (y=0; y<3; y++){
for(z=0; z<4; z++){
fread(&datatabl e[x][y][z],sizeof(short), 24,fp1);

After you solve the problem of where datatable points to, this will
lead to a buffer overflow and undefined behavior. If datatable is
intended to be a 2 x 3 x 4 array of short, then there are only 24
short in the array. If fread is going to read all 24, is should do it
only once and it better start reading from the beginning.
fclose(fp1);
}
}
}
writeheader(&he ader,fp2);
for(x=0; x<2 ;x++){
for (y=0; y<3; y++){
for(z=0; z<4; z++){
fwrite(&datatab le[x][y][z],sizeof(short), 24,fp2);
fclose(fp2);
}
}
}
}
void readheader(HEAD ER *header,FILE *fp1)
{
fread(&(header->num1),sizeof(i nt),1,fp1);
fread(&(header->num2),sizeof(i nt),1,fp1);
fread(&(header->num3),sizeof(i nt),1,fp1);
fread(&(header->num4),sizeof(i nt),1,fp1);
}
void writeheader(HEA DER *header,FILE *fp2)
{
fwrite(&(header->num1),sizeof(i nt),1,fp2);
fwrite(&(header->num2),sizeof(i nt),1,fp2);
fwrite(&(header->num3),sizeof(i nt),1,fp2);
fwrite(&(header->num4),sizeof(i nt),1,fp2);
}

Remove del for email
I changed something in the program but it still reminds that:
*** glibc detected *** double free or corruption (!prev): 0x0887f008
***
Abort (core dumped)
#include<stdio. h>
#include<stdlib .h>
#include<string .h>

typedef struct _HEADER {

int num1;
int num2;
int num3;
int num4;

}HEADER;

int i,j;

void **Allocate2D(lo ng int NBytes, int rows, int columns);
/*here add a function*/
void readheader(HEAD ER *,FILE *);
void writeheader(HEA DER *,FILE *);
main()

{

FILE *fp1;
FILE *fp2;

HEADER header;
short ****datatable;

fp1=fopen("g.da t","r");
fp2=fopen("newd ata.dat","w");
readheader(&hea der,fp1);
datatable = (short ****)Allocate2D (sizeof(short **),2,2);

/*changed here*/

for (i=0;i<2;i++){
for(j=0; j<2; j++){
datatable[i][j] = (short **)Allocate2D(s izeof(short),3, 4);
}
}

for(i=0; i<2 ;i++){
for (j=0; j<2; j++)fread(&data table[i][j][0][0],sizeof(short),
12,fp1);
fclose(fp1);
}

writeheader(&he ader,fp2);

for(i=0; i<2 ;i++){
for (j=0; j<2; j++)fwrite(&dat atable[i][j][0][0],sizeof(short),
12,fp2);
fclose(fp2);
}

/*read the file again*/

}

void readheader(HEAD ER *header,FILE *fp1)
{
fread(&(header->num1),sizeof(i nt),1,fp1);
fread(&(header->num2),sizeof(i nt),1,fp1);
fread(&(header->num3),sizeof(i nt),1,fp1);
fread(&(header->num4),sizeof(i nt),1,fp1);
}

void writeheader(HEA DER *header,FILE *fp2)
{
fwrite(&(header->num1),sizeof(i nt),1,fp2);
fwrite(&(header->num2),sizeof(i nt),1,fp2);
fwrite(&(header->num3),sizeof(i nt),1,fp2);
fwrite(&(header->num4),sizeof(i nt),1,fp2);
}
void **Allocate2D(lo ng int NBytes, int rows, int columns)
{
void **pntr;
int i;

pntr = (void **)malloc(sizeo f(void *)*rows);
pntr[0] = (void *)malloc(NBytes *rows*columns);
for(i=1; i<rows; i++)pntr[i] = pntr[i-1]+(columns*NByte s);
return pntr;
}
/*new function*/
Jul 20 '08 #5
xiao said:

<snip>

fp1=fopen("g.da t","r");
fp2=fopen("newd ata.dat","w");

You were already told why, after attempting to open a file, it's important
to check that the attempt was successful.

Since you've paid no attention to that excellent advice, why should people
bother to offer you any more?

--
Richard Heathfield <http://www.cpax.org.uk >
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jul 20 '08 #6
In article <20************ *************** *******@25g2000 hsx.googlegroup s.com>,
xiao <li*********@gm ail.comwrote:
[reformatted for readability]
for (i=0; i<2; i++)
{
for (j=0; j<2; j++)
{
fwrite(&datatab le[i][j][0][0],sizeof(short), 12, fp2);
}
fclose(fp2);
}
In the first iteration of the outer for loop (i.e. when i = 0),
fp2 is closed at the end of the iteration.
So, in the second iteration (when i = 1),
fwrite is called with an invalid FILE pointer.

Ike
Jul 20 '08 #7
On Jul 20, 1:42 pm, i...@localhost. claranet.nl (Ike Naar) wrote:
In article <20eceb7a-950c-4667-b88e-51d17874f...@25 g2000hsx.google groups.com>,

xiao <littledd...@gm ail.comwrote:
[reformatted for readability]
for (i=0; i<2; i++)
{
for (j=0; j<2; j++)
{
fwrite(&datatab le[i][j][0][0],sizeof(short), 12, fp2);
}
fclose(fp2);
}

In the first iteration of the outer for loop (i.e. when i = 0),
fp2 is closed at the end of the iteration.
So, in the second iteration (when i = 1),
fwrite is called with an invalid FILE pointer.

Ike
Thank you guys~ I tried to do some modification and it seems that the
file does not open correcly.
It reminds me that

"The processing file is ="
WHEN I tried to use command line arguments in it.
Jul 20 '08 #8
On Sun, 20 Jul 2008 09:13:19 -0700 (PDT), xiao <li*********@gm ail.com>
wrote:
snip 100+ lines of old code

If you are going to rework the program, there is no point in requoting
all the irrelevant old code.
>
I changed something in the program but it still reminds that:
*** glibc detected *** double free or corruption (!prev): 0x0887f008
***
Abort (core dumped)
Since you have no calls to free in your program (something else to be
"fixed"), you must be writing to storage beyond the end of some
allocated space. It's not obvious in the code but after you fix the
allocation function things may be easier to spot.

You could try stepping through the code with a debugger.
>

#include<stdio .h>
#include<stdli b.h>
#include<strin g.h>

typedef struct _HEADER {

int num1;
Indenting is useful for declarations also.
>int num2;
int num3;
int num4;

}HEADER;

int i,j;
Why are these global?
>
void **Allocate2D(lo ng int NBytes, int rows, int columns);
While void* is a "generic" object pointer, void** is not. Since you
intend for the return value of this function to be assigned to a
short****, this can cause all kinds of problems with alignments and
sizes.
>/*here add a function*/
void readheader(HEAD ER *,FILE *);
void writeheader(HEA DER *,FILE *);
main()
Use int main(void) if want others to compile your code as part of
helping you.
>
{

FILE *fp1;
FILE *fp2;

HEADER header;
short ****datatable;

fp1=fopen("g.d at","r");
fp2=fopen("new data.dat","w");
Calls to fopen should always be tested for success.
>
How is it you use excessive vertical white space and so little
horizontal? fp2 = fopen is so much easier to read.
>readheader(&he ader,fp1);
datatable = (short ****)Allocate2D (sizeof(short **),2,2);
The presence of the cast should be the first clue that your are doing
something wrong. See the comments in the function.

Isn't it your intent to use the values obtained by readheader instead
of the constants?

If we assume the type issues in the function has been fixed and a
typical system (2 byte short and 4 byte pointers), you first allocate
8 bytes (e.g., 0x10000 - 0x10007). You then allocate 16 more
bytes(e.g., 0x11000 - 0x1100f). When the function returns:
datatable contains 0x10000
datatable[0] located at 0x10000 contains 0x11000
datatable[1] located at 0x10004 contains 0x11008
Continued at the next call...
>
/*changed here*/

for (i=0;i<2;i++){
for(j=0; j<2; j++){
datatable[i][j] = (short **)Allocate2D(s izeof(short),3, 4);
....continued here. For i and j 0: You first allocate 12 bytes (e.g.,
0x12000 - 0x1200b). You then allocate 24 bytes (e.g., 0x13000 -
0x13017). When the function returns:
datatable[0][0] located at 0x11000 contains 0x12000
datatable[0][0][0] located at 0x12000 contains 0x13000
datatable[0][0][1] located at 0x12004 contains 0x13008
datatable[0][0][2] located at 0x12008 contains 0x13010

It looks like there should be enough room for the upcoming fread.
}
}

for(i=0; i<2 ;i++){
for (j=0; j<2; j++)fread(&data table[i][j][0][0],sizeof(short),
12,fp1);
It's usually a good idea to check input operations for success also.
fclose(fp1);
}

writeheader(&h eader,fp2);

for(i=0; i<2 ;i++){
for (j=0; j<2; j++)fwrite(&dat atable[i][j][0][0],sizeof(short),
12,fp2);
fclose(fp2);
}

/*read the file again*/
Useless comments are bad enough. Incorrect ones just add to the
confusion.
>
}

void readheader(HEAD ER *header,FILE *fp1)
{
fread(&(head er->num1),sizeof(i nt),1,fp1);
fread(&(head er->num2),sizeof(i nt),1,fp1);
Well done. Since there is no guarantee the four members of the struct
are adjacent, reading each individually is the best approach. Two
points of style:
-binds more tightly than & so the parentheses around
header->num2 are superfluous. &header->num2 is exactly the same.
At some point you may need to change the type of num2. If you
do, you will also have to change the sizeof(int) argument. You can
make the code "self adjusting" by changing the argument to
sizeof header->num2
or
sizeof(header->num2)
Even though the parentheses are unnecessary, I prefer to use them when
the operand of sizeof is a long expression with additional embedded
operators.
>fread(&(head er->num3),sizeof(i nt),1,fp1);
fread(&(head er->num4),sizeof(i nt),1,fp1);
}

void writeheader(HEA DER *header,FILE *fp2)
{
fwrite(&(heade r->num1),sizeof(i nt),1,fp2);
fwrite(&(heade r->num2),sizeof(i nt),1,fp2);
fwrite(&(heade r->num3),sizeof(i nt),1,fp2);
fwrite(&(heade r->num4),sizeof(i nt),1,fp2);
}
void **Allocate2D(lo ng int NBytes, int rows, int columns)
The return type is useless for this program. The only purpose of
void** is to point to a void*. Nowhere else in your program do you
use any void* and you use the one in this function incorrectly
>{
void **pntr;
int i;

pntr = (void **)malloc(sizeo f(void *)*rows);
NEVER cast the return from malloc.

All allocation calls should always be checked for success.
pntr[0] = (void *)malloc(NBytes *rows*columns);
ESPECIALLY NEVER cast it to the same type it already is.
for(i=1; i<rows; i++)pntr[i] = pntr[i-1]+(columns*NByte s);
This statement contains a constraint violation. Your compiler is
required to produce a diagnostic. Did it? If so why did you ignore
it? (You should not attempt to execute your program until you have a
clean compile.) If it did not produce a diagnostic, either up the
warning level and disengage extensions or get a better compiler.
return pntr;
Let's look at this function in detail as it relates to the first call
from main. For sake of discussion, let's assume
sizeof(short) is 2
sizeof(short*) is 4
sizeof(short**) is 4
sizeof(short*** ) is 4
sizeof(short*** *) is 4
sizeof(void**) is 8
sizeof(void*) is 12
(Yes, these are perverse values but they serve to illustrate the
point.)

The first call to malloc allocates space for 2 void*. If malloc
returns 0x10000, then the first void* is there and the second is at
0x1000c.

The second call to malloc allocates space for 4 short**. If malloc
returns 0x11000, then the first short**is there and the next is at
0x11004 and then 0x11008 and the last at 0x1100c

The for loop will execute exactly once. However, there is no way for
it to compute the value to be assigned to pntr[1]. pntr is a void**.
Therefore pntr[0] is a void*. You cannot do arithmetic on a void*
because the type it points to (namely void) is an incomplete type that
has no size. For purposes of pointer arithmetic, some compiler
extensions (which should be avoided in this group) treat void* as a
char*. In this case, pntr[1] which is located at 0x1000c will be
assigned the value 0x11008.

The return attempts to pass the value 0x10000 as a void** back to main
where it will be cast to a short****. BUT void** is an 8 byte object
and short**** is a 4 byte object and there is no guarantee that it
will fit. This is potentially undefined behavior. There is also no
guarantee that the value of a void** is properly aligned for a
short****. More potentially undefined behavior.

Now look what happens in main. datatable contains the value 0x10000.
datatable is a short****. That means it points to a short***. A
short*** is 4 bytes. Therefore, the short*** it points to (known as
datatable[0]) occupies the bytes from 0x10000 to ox10003 and
datatable[1] starts at 0x10004. But that is not what Alloc2D did. It
stored the two values at 0x10000 through 0x1000b and 0x1000c through
0x10017. More undefined behavior.

Enough academics. Your system may be insensitive to these issues with
short being 2 bytes and int and pointers being 4. But you should be
aware of them. There is no reason to expose your code to these
potential problems. Think about what may happen if you ever upgrade
to a 64 bit system.
>}
/*new function*/

Remove del for email
Jul 20 '08 #9
On 20 Jul, 17:13, xiao <littledd...@gm ail.comwrote:
void **Allocate2D(lo ng int NBytes, int rows, int columns);

*datatable = (short ****)Allocate2D (sizeof(short **),2,2);
Allocate2D returns a void **. It is highly unlikely
that it is usable as a short ****. I haven't looked yet,
but I am already willing to bet that you have made
mistakes in Allocate2D.

>
void **Allocate2D(lo ng int NBytes, int rows, int columns)
{
* * *void **pntr;
* * *int i;

* * *pntr * *= (void **)malloc(sizeo f(void **)*rows);
* * *pntr[0] = (void *)malloc(NBytes *rows*columns);
* * *for(i=1; i<rows; i++)pntr[i] = pntr[i-1]+(columns*NByte s);
* * *return pntr;}
It would be a lot easier if Allocate2D simply returns a short **.
(I don't understand why you've declared datatable a short ****,
since a 2 dimensional array of shorts is typically of type
short **. Your previous code appeared to want a 3 dimensional
array, in which case short *** would be appropriate.)
If you want a 2-dimensional array, you will need to allocate
space to hold a pointer to each row, and then allocate space
for each row. If you only want one allocation, and you
intend to determine the base of each row yourself, then
you don't want a short ** at all, but simply a short *.
For example:

short * two_d_array;
short ** row_ptrs;

two_d_array = xmalloc( rows * columns * sizeof *two_d_array );
row_ptrs = xmalloc( rows * sizeof *row_ptrs );
for( r = 0; r < rows; r++ )
row_ptrs[ r ] = xmalloc( columns * sizeof **row_ptrs );
(xmalloc is a wrapper around malloc that aborts on error.)

BTW, you also really do need to check the return value of
fclose() as well. If you are using fwrite, it is entirely possible
that fwrite will succeed and no error will occur until
after main returns and the streams are flushed. Test
your program (by attempting to write to /dev/null, for
example) and make sure your program generates a useful
warning message.

Jul 21 '08 #10

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

Similar topics

6
1777
by: Peter Hansen | last post by:
Greetings. Im trying to write a program that can be run from the command line. If I want to search for example after a file with the ending .pdf, I should be able to write in the command line: python name of my program / the libary to search and what kind of file it is example a .pdf file So if my program name was test.py and the library name was library1 and the test type i wanted to find was, a .pdf file I should write python...
2
2108
by: janice_2k | last post by:
Dear Sir/Mdm, I am writing this on behalf of my company. We bought the Visual Studio .NET Enterprise version but currently we need to use Visual Basic 6 for a small development. We are not able to purchase it anymore, anywhere we know. Therefore, I would like to know whether is VB 6 still available in the market? If not, is there any way we can 'downgrade' our license to VB 6 for a just short period of time, about 2 months. What other...
3
2497
by: Dean Arpajian | last post by:
Looking to find info/ libs on creating (small) video files. Basically what I'm looking for is a tutorial for constructing a short video... (nothing nasty: output from a transmission line simulation). I've been searching for a while now, and all I get is info for creation inside someone else's app. Rather useless for me. The sim needs to be web accessible. So I was thinking mpeg, quicktime, wmv, avi, etc.
25
2565
by: Tor Erik Sønvisen | last post by:
Hi I need to browse the socket-module source-code. I believe it's contained in the file socketmodule.c, but I can't locate this file... Where should I look? regards tores
18
1663
by: strchild | last post by:
Hey Guys, I've been perusing the newsgroup here for some time now, and going through my ever so non-helpful book, Microsoft Visual Basic .NET Step by Step Version 2003, over and over, and I feel like such a dummy. I read you fella's talking up one side and down the other about streams, and can't for the life of me get a good grasp of them. I've been reading the articles you toss around to each other but I can't quite follow them enough...
34
2973
by: priyanka | last post by:
Hi, I was wondering if we could parse or do something in the executable( whose source language was C). How can I use some scripting language like perl/python to find out the information about the executable ? Is it possible ? Also, how does the compiler add inling to the program ? I know that whenever it sees"inline" in front of the procedure name, it inlines it. But if we give the -finline options, it inline all the procedures ? How
5
3397
by: peter | last post by:
Hello all, I'm looking for an advice. Example (one block in ascii file): $------------------------ NAME='ALFA' CODE='x' $------------------------
11
3699
by: Ko van der Sloot | last post by:
Hello I was wondering which behaviour might be expected (or is required) for the following small program. I would expect that find( "a", string::npos ) would return string::npos but is seems to be dependant on which string is searched for. On my system, using gcc 4.1.2, I get: pos1=2 problem because pos1=0
0
1569
by: Bails | last post by:
Hi All, im in the process of teaching myself VB Express and have chosen to make a Poker Timer as my first project. The project essentially consists of 2 forms as follows: Form1 Contains a DataGridView in which the user sets various information includeing the length of the round, Small Blind, Big Blinde, Ante's etc (this is for a Texas Holdem Tournament which I hope to use for my home games).
4
2644
by: Arthur Dent | last post by:
Hello all, I am trying to figure out how to do something in LINQ, IF I can even do it in LINQ. Online samples and such for LINQ is still a bit on the sketchy side. Here is what I want to do... I have some string, whatever, that doesn't matter. I want to find all the characters which occur in the string more than once.
0
8699
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9293
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7932
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5941
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4456
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4713
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3151
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2508
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.