Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
something useless

 
Post new topic   Reply to topic Printable version
 View previous topic  Netbeans 6.1 (please try to help) Post :: Post The use in ? in php  View next topic  
Author Message
hellzlaker
Registered Cap Buster
Popping men in the ass since Oct 2005


Gender: NEVER ENOUGH!
Joined: Oct 27 2005
Posts: 34
Offline

PostPosted: Fri Oct 31, 2008 8:03 pm    Post subject: something useless Reply to topic Reply with quote

While doing stuff i just made 2 functions which are kind of weird i guess, i just wanted to make them and they might be useful icon_rolleyes.gif

MakeCapital() just changes a char from lower case to upper case, example "bob" will become "BOB"

Pause() will do same as system("pause"); just you can make any message like "bla bla"...


Code: Show/Hide
#include <stdio.h>
#include <windows.h>

char* MakeCapital(char* buf,int size)
{
      for(int i=0;i<size-1;++i)buf[i]-=32;
     
      return buf;
}

void Pause(const char* buf)
{
     printf("%s",buf);
     
     bool paused=true;
     
     while(paused)for(int i=0x08;i<0xFE;++i)if(GetAsyncKeyState(i))paused=false;
}

int main()
{   
     char bob[] = "bob";
     
     printf("%s",MakeCapital(bob,sizeof(bob)));
     
     Pause("\nPress a key!!!");
}
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address MSN Messenger
Adam01
Novice


Joined: Oct 03 2008
Posts: 51
Offline

PostPosted: Fri Oct 31, 2008 8:46 pm    Post subject: Reply to topic Reply with quote

Hmmm...
For Pause(), You could of used getch(), it gets the next input, but doesnt output it.

This a string-to-caps function I think, there certainly is one for php.

But still, great ideas.
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Fri Oct 31, 2008 9:08 pm    Post subject: Reply to topic Reply with quote

toupper will convert characters to their uppercase equivalent without changing things like '1' or '-'.
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Sat Nov 01, 2008 1:26 am    Post subject: Reply to topic Reply with quote

As Brain said, toupper() already does that, but there are 2 things you could improve/fix in your MakeCapital function:

First, you don't need the size... A string is always ended by '\0' (a character with the value 0). So you r continuing condition can be when buf[i] != 0, or even simplier, if buf[i]. If buf[i] is non-null, evaluating "buf[i]" will return true

Code: Show/Hide
char* MakeCapital(char* buf)
{
      for(int i=0; buf[i];++i )
           buf[i]-=32;
     
      return buf;
}


Also, if you don't want characters that are already upper-case, or non-letter characters to be changed by this, you need to add a little if in there...

Code: Show/Hide
char* MakeCapital(char* buf)
{
      for(int i=0; buf[i];++i )
           if (buf[i] >= 'a' && buf[i] <= 'z')
                 buf[i]-=32;
     
      return buf;
}


And yeah, for pause, i think the function is 'getchar()'
Your function probably eats a shitload of CPU :/
_________________
(Insert a bunch of dead links here)
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Sat Nov 01, 2008 8:54 am    Post subject: Reply to topic Reply with quote

toupper only converts a single char, so you'd still need a for loop like the one you've got.
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Sat Nov 01, 2008 3:26 pm    Post subject: Reply to topic Reply with quote

Dr Brain wrote:
toupper only converts a single char, so you'd still need a for loop like the one you've got.
oh, I thought there was one for strings... There's one defined in Mervbot anyway
Back to top
View users profile Send private message Add User to Ignore List
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Non-Subspace Related Coding All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 649 page(s) served in previous 5 minutes.

phpBB Created this page in 0.480042 seconds : 31 queries executed (89.0%): GZIP compression disabled