A Little C/C++

NaOH

Diamond Member
Mar 2, 2006
5,015
0
0
#include "includes.h"

char * function6a (char *arg1, char *arg2)
{
char *ptr1 = NULL;
int var1;
int ii;

while (*arg1 != 0) {

var1 = 1;
ii = 0;
while ( *(arg2 + ii) != 0) {
if ( *(arg1 + ii) != *(arg2 + ii))
var1 = 0;
ii++;
}

if (var1) {
ptr1 = arg1;
break;
}
arg1++;
}

return (ptr1);
}


Analyze!
 

KLin

Lifer
Feb 29, 2000
30,662
902
126
Sub Post()
Dim i As Integer
i = 1
Do While i = 1
Debug.Print "this thread sucks"
Loop
End Sub


Better ;)
 

NaOH

Diamond Member
Mar 2, 2006
5,015
0
0
Originally posted by: KLin
Private Sub Post()
Dim txtPost as string
txtPost = "This thread sucks"
Do While True = False
debug.print txtPost
Loop
End Sub

:p
 

KLin

Lifer
Feb 29, 2000
30,662
902
126
Originally posted by: NaOH
Originally posted by: KLin
Private Sub Post()
Dim txtPost as string
txtPost = "This thread sucks"
Do While True = False
debug.print txtPost
Loop
End Sub

:p

My logic doesn't work, I suck :(
 

Descartes

Lifer
Oct 10, 1999
13,968
2
0
Are you asking a question? With a 5 second glance, it looks like you're trying to write some kind of a contains method for strings. It's very poorly written though unless you're getting extra credit for obfuscation (arg1, arg2, ii... huh?).

 

Cooler

Diamond Member
Mar 31, 2005
3,835
0
0
use the STL string class and never work with C strings again. BTW i just did quick look and it looks it checks if the second word is a sub string of the first. if so it returns the first word. Nicer looking code would have used arg2[ii] arg1 and '\0' for checking for null char.