473,508 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Colour output to the console

51 New Member
(in C programing)
who knows the name of some function which can be used for printing tables or for printing some colorful outputs?
i want to print some data in red color and also want to print and scan some data in table,what shuold i do?
Jan 13 '07 #1
7 3378
Ganon11
3,652 Recognized Expert Specialist
Please do not double-post your questions. It will not help them get answered more quickly, it only clutters up the thread list. The second topic has been deleted.
Jan 13 '07 #2
Banfa
9,065 Recognized Expert Moderator Expert
colour printing depends entirely on the platform you are using. We will need to know the platform to be able to help.
Jan 13 '07 #3
khajeddin
51 New Member
well,i actually don't understand what you mean from"platform "...!
if you mean the style of my program...well,i have to write a program which make a file for storring data and then using these data in some function...
(data will be taken in form of structures) .here is a piece of this:

Expand|Select|Wrap|Line Numbers
  1.  #include<stdio.h>
  2. #include<conio.h>
  3. #include<stdlib.h>
  4. #include<string.h>
  5.  struct INFORMATION{
  6.         long student_number;
  7.         char first_name[20];
  8.         char last_name[20];
  9.         float grade[100];
  10.         int grade_number;
  11.         int unit[100];}info[50];
  12. int menu(void);
  13. void add_student(void);
  14. void view_student(void);
  15. void main()
  16.   {
  17.      clrscr();
  18.      for(;;)
  19.         switch(menu()){
  20.             case 1 : add_student(); break;
  21.             case 2 : view_student(); break;
  22.             case 6 : exit(1);
  23.               }/*End of switch & for*/
  24.      }/*End of main*/
  25. int menu(void)
  26.   {
  27.      int index;
  28.  do{  clrscr();
  29.      gotoxy(5,5);
  30.      printf("<<menu of choices:>>");
  31.      gotoxy(5,7);
  32.      printf("1) Adding a student.");
  33.      gotoxy(5,9);
  34.      printf("2) viewing a student's information.");
  35.      gotoxy(5,11);
  36.      printf("3) Editting a student's information.");
  37.      gotoxy(5,13);
  38.      printf("4) Deleting a student.");
  39.      gotoxy(5,15);
  40.      printf("5) List of students' information.");
  41.      gotoxy(5,17);
  42.      printf("6) Exit setup.");
  43.      gotoxy(5,19);
  44.      printf("enter you select,then press Enter key:");
  45.      scanf("%d",&index);}
  46.      while(6<=index && index<=1);
  47.      return index;
  48.      }/*End of menu function*/
  49. //**************************
  50. void add_student()
  51.   {
  52.     FILE *ptfile;
  53.     static int m=0;
  54.     int course_no=0, index, index1;
  55.     char strno[20];
  56.     clrscr();
  57.     getch();
  58.     ptfile=fopen("fmain.dat","a");
  59.     if(!ptfile)
  60.       {printf("\n can not open the file.");
  61.         getch();
  62.         exit(1);}
  63.         for(index=0 ; index<50 ;index++)
  64.         { info[index].first_name[0]='\0' ;
  65.           info[index].last_name[0]='\0' ;
  66.           info[index].grade[0]='\0' ;
  67.           info[index].unit[0]='\0' ;
  68.           info[index].student_number=0;
  69.           info[index].grade_number=0;}
  70.     info[m].grade_number=0;
  71.     gotoxy(5,5);
  72.     printf("Please enter the student number:");
  73.     scanf("%s",strno);
  74.     info[m].student_number=atoi(strno);
  75.     gotoxy(19,7);
  76.     printf("first name :"); scanf("%s",info[m].first_name);
  77.     gotoxy(19,9);
  78.     printf("last name :");  scanf("%s",info[m].last_name);
  79.     gotoxy(19,11);
  80.     printf(" number of courses :");
  81.     scanf("%d",&course_no);
  82.     for(index1=0 ; index1<course_no ;index1++)
  83.         {gotoxy(19,13);
  84.          printf("grade of course number %d .",index1+1);
  85.          scanf("%s",strno);
  86.          info[m].grade[index1]=atoi(strno);
  87.          gotoxy(19,15);
  88.          printf("unit of course number %d .",index1+1);
  89.         scanf("%s",strno); info[m].unit[index1]=atoi(strno);
  90.  
  91.  (info[m].grade_number)+=(info[m].grade[index1])*(info[m].unit[index1]);}
  92.     (info[m].grade_number)/=course_no ;
  93.     fwrite( &info[m] , sizeof(INFORMATION), 1 ,ptfile);
  94.     m++;
  95.     fclose(ptfile);
  96.     printf("Press any key to continue...");
  97.     getch();
  98.     }
  99. void view_student()
  100.   {
  101.     clrscr();
  102.     FILE *ptfile;
  103.     long number=0,variable=0;
  104.     char strno[20];
  105.     int index=0 ,index1;
  106.     ptfile=fopen("fmain.dat","r");
  107.     if(!ptfile)
  108.         { printf("can not open the file.");
  109.          getch();
  110.          exit(1);}
  111.     printf("Please enter the student's number:\n");
  112.     scanf("%s",strno);  number=atoi(strno);
  113.     fread( &info[index], sizeof(INFORMATION) ,1,ptfile);
  114.     for( index=0 ;  !feof(ptfile) ;index++)
  115.      { if(number==info[index].student_number)
  116.       {
  117.        gotoxy(5,5);
  118.        printf("number: %ld",info[index].grade_number);
  119.       gotoxy(5,6);
  120.                   printf("first name: %s",info[index].first_name);
  121.       gotoxy(5,7);
  122.       printf("last name: %s",info[index].last_name);
  123.       gotoxy(5,9);
  124.        printf("avrage: %d",info[index].grade_number);
  125.        gotoxy(5,10)  ;
  126.        for(index1=1; info[index].grade;index1++)
  127.  
  128. {printf("%d) %f %d",index1,info[index].grade[index1],info[index].unit[index1]);
  129.     gotoxy(5,10+index);
  130.             }
  131.     variable=number;
  132.          }
  133. fread( &info[index+1], sizeof(INFORMATION) ,1,ptfile);
  134.                      }
  135.       if(!variable)
  136.       printf("can not find the student\n");
  137.       fclose(ptfile);
  138.     printf("press any keyto continue...");
  139.     getch();
  140.  
  141.     }/*End of view_student*/
  142. //****************************************
  143.  
Jan 14 '07 #4
Banfa
9,065 Recognized Expert Moderator Expert
colour printing depends entirely on the platform you are using. We will need to know the platform to be able to help.
By platform I mean

What OS
What Compiler
What Computer/CPU Chipset
Jan 14 '07 #5
khajeddin
51 New Member
By platform I mean

What OS
What Compiler
What Computer/CPU Chipset
microsoft
Turbo C++ 4.5
intel(R)
Jan 14 '07 #6
Banfa
9,065 Recognized Expert Moderator Expert
I believe the Borland C++ has a function cprint or cprintf that outputs in colour. But you will have to look it up as I do not know anything about it.
Jan 14 '07 #7
Ganon11
3,652 Recognized Expert Specialist
You can also use a system() call to generate basic background and text colors. Open up a command prompt and type "color fg" to get the basics on how it works. In your program, you will use a call like

Expand|Select|Wrap|Line Numbers
  1. system("COLOR XY");
where X and Y are color constants that you will see in your command prompt when you test it out.
Jan 14 '07 #8

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

Similar topics

3
3694
by: Liren Zhao | last post by:
I use some "Console.WriteLine(some strings here)" to display some debug information in my winform program. How can I get the information in my programe or same them in a text file ?
4
2952
by: Bob | last post by:
I just recently noticed that when I start my applicatoin in debug mode, the IDE hangs (no disk or CPU activity) indefinitely (at least 20 minutes). Pausing the application shows that it's hung up...
2
4732
by: Steve | last post by:
I have created a console app that simply prints out a message a couple times, then exits, here is the code: <code> for(int i = 0; i < 10; i++) { System.Threading.Thread.Sleep(500);...
1
3797
by: lavu | last post by:
I currently have a C# windows Application . I would like this App to work through an command line interface also. I would like to specify command line params, which should start the app and process...
5
2355
by: Anton81 | last post by:
Hi all! I used escape sequences to produce colour output, but a construct like print "%8s" % str_with_escape doesn't do the right thing. I suppose the padding counts the escape characters,...
4
9454
by: gurdz | last post by:
Does anyone know how to change the colour of the text in the console in C??
1
1323
by: skeete1990 | last post by:
heres my code there 1 problem with it (its bolded) its not going through its a math type things if any one can help me please help all i ask is that you no change the code too much if possible, heres...
3
3433
by: pratap | last post by:
I have an application which periodically gives me an output of sonar values .However i am unable to view the values as they get replaced by the new ones below in realtime and are displayed after...
1
8344
by: mquincey | last post by:
One of the features offered by .NET 2.0 is the use of the TraceSource class. In an attempt to demonstrate its use, I wanted to run my test under the following conditions: 1. Use TraceSource class...
0
7227
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7127
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
5633
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5056
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4713
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1564
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
424
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.