Raised This Month: $ Target: $400
 0% 

can someone convert the c++ code to amxx


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DaBears
New Member
Join Date: May 2009
Old 05-26-2009 , 01:23   can someone convert the c++ code to amxx
Reply With Quote #1

Quote:
#include <stdio.h>
#include <string.h>

void main()
{
char *buf = "127.0.0.1";
int a,b,c;
char buf2[15]={0};

char *p = strrchr(buf,'.');
if(p)
{
memcpy(buf2,buf,p-buf);
}

printf("%s\n",buf2);
}
DaBears is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 05-26-2009 , 02:02   Re: can someone convert the c++ code to amxx
Reply With Quote #2

PHP Code:
    new buf[] = "127.0.0.1"
    
new buf2[sizeof buf]

    new 
pos = -1

    
for(new sizeof buf i>= 0i--)
    {
        if (
buf[i] == '.')
        {
            
pos i;
            break;
        }
    }
        
    if(
pos != -1)
    {
        
copy(buf2,pos 1,buf)
    }

    
server_print("Buf2 = ^"%s^"^n",buf2
Try this. I didn't tested it yet. I'm gonna test it in some minutes

Edit: I tested it. It prints:

Buf2 = "127.0.0."

I think that's what you want. If you want it to print Buf2 = "127.0.0", change the "pos + 1" given to copy() by "pos"
__________________

Last edited by joaquimandrade; 05-26-2009 at 02:15.
joaquimandrade is offline
DaBears
New Member
Join Date: May 2009
Old 05-26-2009 , 05:53   Re: can someone convert the c++ code to amxx
Reply With Quote #3

Quote:
If you want it to print Buf2 = "127.0.0", change the "pos + 1" given to copy() by "pos"
omg!this is what i want !how do you know my mean?!
i'll test it soon !
thank you !
DaBears is offline
DaBears
New Member
Join Date: May 2009
Old 05-27-2009 , 19:10   Re: can someone convert the c++ code to amxx
Reply With Quote #4

hi ,it's work good.

thanks again!
DaBears is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 01:34.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode