Re: String Comparision
Default User wrote:
user34 wrote:
I did not retype the code !
Here it is once again (without any of the above suggested
improvements)and it still shows me the same error!
#include<stdio.h>
int comp(char *s,char *t)
{
for(;*s==*t;s++,t++);
^
That semicolon doesn't belong.
Or maybe it did. Either way, it's not going to work.
If you leave the semicolon in, then if the strings are identical then
you read off the end of each into memory that might not belong to the
strings, or memory that had never been initialized. At any rate, it
will report a false mismatch, because it will continue that until
there's a difference.
Brian
.
Relevant Pages
- Re: .NET SUCKS --- READ FOLLOWING. MICROSOFT IS A SUCKY CO
... > system just doesn't cut it in high memory load situations. ... Garbage Collection is not an excuse for poor memory management. ... One excellent example is the use of strings. ... because many "professional" programmers know very little about what is ... (microsoft.public.dotnet.framework) - Re: Secure Credentials pwd handling
... strings that are produced when you read the properties. ... Co-author of "The .NET Developer's Guide to Directory Services Programming" ... so at some point the value will be in memory. ... SecureString is added to .NET to support this use case. ... (microsoft.public.dotnet.security) - Re: CStrings and memory
... Then you allocate a few more strings ... Now you need to allocate another string, but there is no more memory. ... In addition to strings, there are other things that get allocated: ... have perhaps confused "address space" with "working set". ... (microsoft.public.vc.mfc) - Re: Verbose functional languages?
... whereas a memory leak due to too much laziness in the wrong place can be. ... If you declare your data structure elements as strict, ... I think size matters, for the optimization heuristics. ... strings for symbol names. ... (comp.lang.functional) - Re: mex: cell (of strings) allocation
... strings and numeric data, and returns the numeric data in a ... and the strings in a cell array of strings. ... cannot seem to use the same idiom for the cell of strings. ... *exactly* the same amount of memory you originally ... (comp.soft-sys.matlab) |
|