|
-
January 22nd, 2005, 12:04 PM
#1
little help
I having little problem adding a "-" to 20 charaters.. for example,
0K4CJQ6K7301T1159251
i was trying separate the long string by 4 and after every 4 charaters would add "-"
like this 0K4C-JQ6K-7301-T115-9251
how would i do this? i know looping is involve but dont know how to put together..
thank you for your time
-
January 23rd, 2005, 11:02 AM
#2
Re: little help
Code:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
const char *szKey = "0K4CJQ6K7301T1159251";
char szEnd[256] = "";
int i = 0;
int iLen = strlen(szKey);
printf("Key before processing: %s\n", szKey);
for ( i = 0; i < iLen; i += 4 )
{
if ( i )
{
strcat(szEnd, "-");
}
strncat(szEnd, (szKey+i), 4);
}
printf("Key after processing: %s\n", szEnd);
system("PAUSE");
return 0;
}
This was 5 minuite work. Hope this helps.
-
January 23rd, 2005, 12:53 PM
#3
Re: little help
whoa!
thanks for the codes.
-
January 24th, 2005, 05:12 AM
#4
Re: little help
 Originally Posted by mc0282
whoa!
thanks for the codes.
You are very welcome.
/ I hope you do not need it for an illegal keygen
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
|