Linux -Blue forest free software | Return to home page | Site Map | Search WWW | Contact Us |
Your current position : Homepage > Free Software > Technological exchanges >Application Programming


    

Blue Forest http://www.lslnet.com at 10:18 on June 6, 2006


Strstr -- have Segmentation fault.

[code]
#include<stdio.h>;
#include<string.h>;

Int
Main () {// seeking string "ab" in which the number of string;
*string Char = "sdfabsdfsdabfsdfabkhjk";
Char *p;
Int i = 0
For (p = p> string; NULL; i++) (
P = strstr (p, "ab");
P = p+2;
        }
Printf ( "%d\n", i);
Return 0
}       
                       
                       
[/code]
Gcc test.c
Gives no warning

Strstr -- have Segmentation fault.

P!=NULL conclude how the judge can use *p!= "\0" the judge concluded. [/i]

Strstr -- have Segmentation fault.

Strstr -- have Segmentation fault.

I am sorry, I did not feel right, in order to express regret, I am writing to you out.
#include<stdio.h>;
#include<string.h>;

Int
Main () {// seeking string "ab" in which the number of string;
Int n;
*string Char = "sdfabsdfsdabfsdfabkhjk";
Char 6-12, *q;
Int i = 0
N=strlen (string);
P=string;
For (q=p+n; p<=q; i++) (
P = strstr (p, "ab");
If (p==0)
      {
Break;
      }
P = p+2;
       }
Printf ( "%d\n", i);
Return 0
}

Strstr -- have Segmentation fault.

Strstr p==NULL is the return value, it added two of you do not do so, the final say if the two characters is the string "ab" how do, p. not return 0 (NULL) plus two is not out of the scope.

Strstr -- have Segmentation fault.

Xiongtai kind, thank you Huitie
Strstr -- have Segmentation fault.

-->

Wrong. You did not write, but read a. But this might create Segmentation fault.
Transboundary pointer in C language is very dangerous, because there is no way you can determine what will happen.

Strstr -- have Segmentation fault.


Strstr -- have Segmentation fault.

[code]
Gdb debugging through
Segmentation fault found in the 4th cycle
3rd cycle when p = 0x804852a "khjk"
Executive p = strstr (p, "ab"); After
P = 0x2 "Address bounds>; 0x2 out of the 4003rd return NULL is not a bargain
How else?
[/code]

Strstr -- have Segmentation fault.

P = 0x2 "Address bounds>; 0x2 out of the 4003rd return NULL is not a bargain
How else?
====
Ah you take a look at your procedures.
Strstr () return NULL.
But you allowed this time p=0x02; p+=2;
Laughter. . . . . . . Aware of the wrong religion?

Strstr -- have Segmentation fault.

-->

Do not understand how that is read?
Could you please share some details of the revised guidelines variables?
Thanks

Strstr -- have Segmentation fault.

-->
P = strstr (p, "ab");
This is a read for 2160.
If you do not read, how it strstr () 啊???

Strstr -- have Segmentation fault.

";>;p = P+2;
In other words, if the operation at a previous p is NULL, then p + 2 days pointed happened to know that this is the way to invalid addresses the read operation.

Strstr -- have Segmentation fault.

-->
Put it right.
In the vast majority of system that is NULL mo (void *) 0.
But I did not know that some system that will not NULL 0.
P=NULL
P+=2;
P where to go, the only heaven knows.

Strstr -- have Segmentation fault.

In short, the operation is carried out on a car at the time it should address to ensure the effectiveness of mistakes will not read or write, basically most of the rules governing powers are such to the fault.

Commander of the code is to give you more of a judgment :
If (p==0)
{
Break;
}

Strstr -- have Segmentation fault.

-->
TU know : em02 em02 : : : : : em02
Thanks


Who can tell if some of the details on the revised guideline variables better

On the export of gdb debugging information to document what?

Strstr -- have Segmentation fault.

-->

Your answer is right! Em02 : : : : : em02 : em02
I took the opportunity to talk about the two issues mentioned above

Strstr -- have Segmentation fault.

1) "c programming experts" from c is a good guide book on the grammar level, if we want to have a better understanding and be out of the bottom to recommend the "depth understanding of computer systems". Find a book to see the books is the best teacher.

2) sorry, do not know that



 Privacy Policy  Copyright © 1999-2000 LSLNET.COM. All rights reserved. Blue Forest website owners. E-mail : Webmaster@lslnet.com