By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,058 Members | 1,217 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,058 IT Pros & Developers. It's quick & easy.

Need help with strings and coloring text fast, please.

P: 2
Hi, I wanna know how to avoid the program to scan only the first letter of a string... I know it sounds real n00bish, but if you could post a simple example (SIMPLE, not like the help menu from c++) through C++ it'd be awesome :D.

Also, I would like to know how to color a text (What library should be used, how do you use a variable to color the text, and so on...).


P.S: The reason I need it fast is because I need to deliver a work tomorrow at college (about 30% of the total grade).

Thanks a lot in advanced. :)
Nov 23 '06 #1
Share this Question
Share on Google+
3 Replies


sivadhas2006
100+
P: 142
Hi,

To skip the character use the following function.

Expand|Select|Wrap|Line Numbers
  1. getch()
  2.  
To print the colorful text use the following functions.

Expand|Select|Wrap|Line Numbers
  1. textcolor(WHITE); and 
  2. cprintf("Colored Text")
  3.  
  4.  
Regards,
M.Sivadhas.
Nov 23 '06 #2

P: 3
I wanna know how to avoid the program to scan only the first letter of a string...

Hi
try
#include<iostream.h>

void main()
{
char str[10];
cout<<"\n Enter name";
cin.getline(str,10);
cout<<str;
}
It will alow you to enter 9 char because last char in array has to be \0. User can enter more letters on the screen but only first 9 will be in str. You can vary second argument of getline() which is no of char you want to enter remember to change str to the same number or bigger.
good loock
Nov 23 '06 #3

P: 2
Thanks you guys ^^ That helped a lot :)
Nov 23 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.