Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Reading user input

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
ManOnMoon
Cheater
Reputation: 0

Joined: 17 Mar 2009
Posts: 26

PostPosted: Tue Mar 02, 2010 6:47 pm    Post subject: Reading user input Reply with quote

Sorry for the constant questions I ask on this forum without much contribution but it is easer for me to learn when i ask since my proff confuses me =(


Well time for my problem. We have to make a vigenere cipher except I dont know how to read the user input since we are not allowed to limit the string. When I asked him he said to read it letter by letter and copy it into a string but I dont know how to do that.
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Tue Mar 02, 2010 7:05 pm    Post subject: Reply with quote

getchar() ?
Back to top
View user's profile Send private message
ManOnMoon
Cheater
Reputation: 0

Joined: 17 Mar 2009
Posts: 26

PostPosted: Tue Mar 02, 2010 8:26 pm    Post subject: Reply with quote

Will get char give me each char of the inputed line though? or will I need to use it for everyline
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Tue Mar 02, 2010 8:37 pm    Post subject: Reply with quote

yes it gets each char. including \n
Back to top
View user's profile Send private message
ManOnMoon
Cheater
Reputation: 0

Joined: 17 Mar 2009
Posts: 26

PostPosted: Tue Mar 02, 2010 9:08 pm    Post subject: Reply with quote

Oh ok awesome then I'll do that and cut off the '/n' for '/0'
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Tue Mar 02, 2010 9:37 pm    Post subject: Reply with quote

well another way you can do this is to read in everything. then tokenise it with strtok()
Back to top
View user's profile Send private message
ManOnMoon
Cheater
Reputation: 0

Joined: 17 Mar 2009
Posts: 26

PostPosted: Tue Mar 02, 2010 10:24 pm    Post subject: Reply with quote

How exactly do I use getchar()? I have never needed to use it so I don'tknow how it would help if you could give


*edit

I should clarify

Say I have the input 'To be or not to be'
and I want to copy it into a string without using fgets
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Tue Mar 02, 2010 10:54 pm    Post subject: Reply with quote

http://www.cplusplus.com/reference/clibrary/cstdio/getchar/
_________________
Back to top
View user's profile Send private message
ManOnMoon
Cheater
Reputation: 0

Joined: 17 Mar 2009
Posts: 26

PostPosted: Tue Mar 02, 2010 11:12 pm    Post subject: Reply with quote

I understand how it works but my programs specs does not ask the user to type anything its supposed to assume that they know what to type and then takes that string and enciphers it. What I want to do is copy it one bye one into a string. Based off the link you just gave me I cane up with this
except I dont know how to limit 'i' since i dont know how long the user input will be and i can't limit it




Code:
         for (i=0;/*insert when to stop*/;i++){
               do {
               c=getchar();
               putchar (c);}
               while (c != '/n')
               message[i] = c;         
               return i;
            }
Back to top
View user's profile Send private message
Slugsnack
Grandmaster Cheater Supreme
Reputation: 71

Joined: 24 Jan 2007
Posts: 1857

PostPosted: Wed Mar 03, 2010 5:22 am    Post subject: Reply with quote

look at that link above, and read the 'return value' part
Back to top
View user's profile Send private message
ManOnMoon
Cheater
Reputation: 0

Joined: 17 Mar 2009
Posts: 26

PostPosted: Wed Mar 03, 2010 11:26 pm    Post subject: Reply with quote

Thank you so much for that link I ended up figuring it out as well as clarifying other questions I had
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot 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 cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites