Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

fucking c functions

Name: Anonymous 2009-03-22 13:00

I need a shitty function to tell me if a string contains another - i.e. it should return true for "you are a faggot" and "asdfaggotsds" provided the second string is faggot, in c. I'm obviously too lazy to write it myself since it's a small part of an unnecessarily large homework and my inadequate googling skills prevented me from finding out what it should be - I assume /prog/ can guide me successfully as you are all [b]EXPERT PROGRAMMER[b]s who know all this shit.

Name: Anonymous 2009-03-22 13:00

in after bbcode failure

Name: Anonymous 2009-03-22 13:12

strstr

Name: Anonymous 2009-03-22 13:19


#include string
using namespace std;

int yourAFaggot(string faggot, string otherFag)
{
     return faggot.find(otherFag);
}

Name: Anonymous 2009-03-22 13:20

>>3
ahh thanks

Name: Anonymous 2009-03-22 13:21

The difficulty of googling a string.h reference.

Name: Anonymous 2009-03-22 13:39

"faggot" ^isInfixOf^ "you are a faggot"

Name: Anonymous 2009-03-22 13:42

you can solve this problem using dynamic programming which is just a form of recursion

Name: Anonymous 2009-03-22 14:17

you can troll /prog/ which is just a form of recursion.

Name: Anonymous 2009-03-22 15:17

you can hax my anus which is just a form of buttsex

Name: Anonymous 2009-03-22 17:33


int lenToSearch = GetLength(toSearch): //make getlength; that's //easy.
int lenLookFor = GetLength(toLookFor)
for (int gay = 0; gay < lenToSearch; gay++)
{  
   int matcher = 0;
   while(toLookFor[matcher] == toSearch[gay])
   {
       matcher++;
       if (matcher == lenLookFor)
          return (gay - matcher); //return the start pos
   }
}
return -1; //return not found
 

lol 1 iz l33t h/\><0rz

Name: Anonymous 2009-03-22 18:03

Name: Anonymous 2009-03-22 18:06

man strstr you stupid faggot

c has extensive string manipulation abilities. unfortunately they are no wrapped up in a nice class.

unfortunately often people dont know of them until they are an [c]EXPERT C PROGRAMMER[/b].

If you are on a unix-type system, I recommended reading all of these -

ls /usr/share/man/man3/str*

as you may end up saving yourself a lot of work.

Having said that, I have a custom set of str functions i make use of also in my projects - things like a variadic strdup that you can pass a bunch of strings to and it concatenates them to a newly allocated string.. to make c strings a bit more convenient.

Name: Anonymous 2009-03-22 18:17

>>13
strstr
Pronounced struh-struh

Name: Anonymous 2009-03-22 18:19

>>14
agreed

Name: Anonymous 2009-03-22 18:28

>>14
I pronounce it ``stir-stir'' (faggot).

Name: Anonymous 2009-03-22 18:30

Ubanto

Name: Anonymous 2009-03-22 18:32

>>16
I say ``string string'' (also faggot).

Name: Anonymous 2009-03-22 18:33

>>17
look for
manpages-posix-dev - for c headers
manpages-dev - for c functions

Name: Anonymous 2009-03-22 18:43

>>19
look for
a better linux distro

Name: Anonymous 2009-03-22 18:50

>>19
wait what, how did you manage to reply to >>17, which contained a single word ``Ubanto''?

Name: Anonymous 2009-03-22 18:52

>>21
I presumed he was refering to the lack of man pages in Ubuntu

Name: Anonymous 2009-03-22 19:05

>>22
lack of *
Ubuntu
I think you got the wrong distribution. Ubuntu is about including absolutely every peice of software and information under the sun in the main releases.

Name: Anonymous 2009-03-22 19:08

>>23
i meant it isn't included by default, sorry for the confusion

Name: Anonymous 2009-03-22 19:09

>>24
you will be

Name: Anonymous 2009-03-22 19:14

>>23
Well that would make sense, it is based off of Debian after all.

Name: Anonymous 2009-03-22 21:30

Fuck. We now have some programming threads, but they all seem to be retarded.

Name: Anonymous 2010-12-17 1:33

Xarn is a bad boyfriend

Don't change these.
Name: Email:
Entire Thread Thread List