473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How can I print a red "Hello world"

It seems that the standard c library doesn't give any support on
this. I googled this question and found that the code would not be
portable. Then how can I do this under linux ? Thanks! ^_^
Jun 27 '08 #1
3 1459
Gestorm <zh********@126.comwrites:
It seems that the standard c library doesn't give any support on
this. I googled this question and found that the code would not be
portable. Then how can I do this under linux ? Thanks! ^_^
You can start by asking in a Linux-specific newsgroup.

(Note that this might not be possible under Linux, depending on the
nature of the terminal or terminal emulator you're using.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 27 '08 #2
On Sun, 15 Jun 2008 19:38:01 -0700, Gestorm wrote:
It seems that the standard c library doesn't give any support on this.
I googled this question and found that the code would not be portable.
Then how can I do this under linux ? Thanks! ^_^
It is not a Linux specific thing it is a terminal type specific thing.
On my terminal I can use:

fputs( "\033[31mHello World!\n", stdout );

Lookup the different codes on:
http://www.ibm.com/developerworks/li.../l-tip-prompt/

in particular, lookup the code for how to reset it back to what might be
the "correct" colour. My PS1 (prompt) variable does this for me so I
haven't included it above.

If you want to play with this sort of thing, remember that when you screw
up your terminal, you can usually type reset[enter] to get it back, and
this usually works even if you can't see the letters coming up.
Jun 27 '08 #3
On Jun 16, 2:10 pm, viza <tom.v...@gmil.comwrote:
It is not a Linux specific thing it is a terminal type specific thing.
On my terminal I can use:

fputs( "\033[31mHello World!\n", stdout );

Lookup the different codes on:http://www.ibm.com/developerworks/li.../l-tip-prompt/

in particular, lookup the code for how to reset it back to what might be
the "correct" colour. My PS1 (prompt) variable does this for me so I
haven't included it above.

If you want to play with this sort of thing, remember that when you screw
up your terminal, you can usually type reset[enter] to get it back, and
this usually works even if you can't see the letters coming up.
Very helpful, thanks!
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: ME | last post by:
I am trying to find a prewritten method for converting a string like this:"Hello World" to this "Hello\sWorld". I plan to use it to build a regular expression. Specifically I am looking for a...
33
by: ankursinha | last post by:
Hi, Is it possible to write a C program that prints "Hello World" on screen without having a single semi-colon in the entire program? The extra constraint here is that u r not allowed to use...
1
by: ranveerkunal | last post by:
where are string literals stored : data segement, stack ex. char *test() { return("hello"); } int main() { puts(test()); return 0;
8
by: vijay | last post by:
Hello, As the subject suggests, I need to print the string in the reverse order. I made the following program: # include<stdio.h> struct llnode { char *info;
16
by: saurabhnsit2001 | last post by:
The following program doesn't "seem" to print "hello-out". (Try executing it) #include <stdio.h> #include <unistd.h> int main() { while(1) { fprintf(stdout,"hello-out");
13
by: jningombam | last post by:
Hi all, Could anyone please help me to print "Hello World" in C programming language without including any code inside main function Regards.
4
by: arnuld | last post by:
i am learning C and doing the exercise 1-1 of K&R2, where K&R ask to remove some parts of programme and experiment with error, so here i go: #include <stdio.h> int main () { printf('hello...
5
by: Andrea | last post by:
Hi, I'm a newbie i want to know how can i convert string to its binary representation, i want to write a program where an example string "hello world" is transformed in his binary representation...
0
by: Gerardo Herzig | last post by:
Hi all. Im having some "problems" with a small concurrent plpython function. Based on a small example about concurrent programming, there is some code which works fine under python: #!...
2
by: Bill H | last post by:
Everyone probably started with the infamous print "hello world" as their 1st program. I am looking for a site online that basically does the same for php & database communication. A site that walks...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.