|
-
Aug 6th, 2002, 08:04 PM
#1
Thread Starter
Fanatic Member
removing last 5 or 6 chars
ive got a ip like: <ip>:<port>
i wanna strip teh :<port>
there what i came up with
Code:
bool passed=false;
for(int i=0;i<=strlen(server_name);i++){
if(passed){
*server_name=' ';
} else{
if(*server_name==':'){
*server_name=' ';
passed=true;
}
}
*server_name++;
}
it returns the lst 8 with the port, and i cant figure out why
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Aug 7th, 2002, 07:45 PM
#2
Frenzied Member
Code:
char *buf;
buf = server_name;
buf+=strlen(server_name) -1;
while(*buf!=':'){
*buf-- = 0x00;
}
*buf = 0x00;
}
voila...
-
Aug 7th, 2002, 08:34 PM
#3
Fanatic Member

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Aug 7th, 2002, 08:39 PM
#4
Thread Starter
Fanatic Member
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Aug 7th, 2002, 08:44 PM
#5
Fanatic Member
cool!! where do you see all these weird characters?

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Aug 7th, 2002, 10:52 PM
#6
PowerPoster
Originally posted by prog_tom
cool!! where do you see all these weird characters?
They are at the end of every string.
-
Aug 8th, 2002, 08:14 AM
#7
Fanatic Member
how come I never seen any of them, previously?

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Aug 8th, 2002, 02:49 PM
#8
Ya ya Baby!!!Me is Back
0x00 = 0
it's hexadecimal....
and what you call weird character is ASCII caracter.
in all C++ book it have an introduction about that.
-
Aug 8th, 2002, 02:53 PM
#9
Thread Starter
Fanatic Member
Originally posted by jim mcnamara
Code:
char *buf;
buf = server_name;
buf+=strlen(server_name) -1;
while(*buf!=':'){
*buf-- = 0x00;
}
*buf = 0x00;
}
voila...
it returns a blank
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Aug 8th, 2002, 03:10 PM
#10
Frenzied Member
huh? this code prints everything up to but not inclusing the ':'
Code:
#include <stdio.h>
int main(){
char server_name[100];
char *buf;
memset(&server_name,0x00,sizeof(server_name));
strcpy(server_name,"101.101.0:asb");
buf = server_name;
buf+=strlen(server_name) -1;
while(*buf!=':'){
*buf-- = 0x00;
}
*buf = 0x00;
printf("%s\n",server_name);
}
The only possible difference is that server_name here is an sz string.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|