Question

S

SM Ryan

# How can I say 'I love you.' in C?

There are many different Cs, and if you choose the wrong one, you risk
physical injury. One way is to find a friend with a piano, and have
her repeatedly hit one of the C keys. Hum with it until you get the
tone, then try speaking "Je t'aime' in the same tone.
 
W

Walter Roberson

#include <stdio.h>
int main(void)
{
puts("I love you.");
return 0;
}

Careful, the "I love you." might get lost, covered over by the next
prompt, or lost in the filesystem. To avoid undesirable behaviour,
add in a \n to the string.
 
A

Alan Balmer

Careful, the "I love you." might get lost, covered over by the next
prompt, or lost in the filesystem. To avoid undesirable behaviour,
add in a \n to the string.

puts() always adds a newline.
 
R

Robert Gamble

Walter said:
Careful, the "I love you." might get lost, covered over by the next
prompt, or lost in the filesystem. To avoid undesirable behaviour,
add in a \n to the string.

Careful, if you don't pay attention to the posted code you might
confuse a function that automatically prints a \n with one that doesn't
and say something silly.

Robert Gamble
 
J

James6.0

-fat_gay_man-@pieshop$ vi iloveyou.c

#include <stdio.h>

int main(void) {
printf("I Love You");
return 0;
}
:wq
-fat_gay_man-@pieshop$ cc -o iloveyou iloveyou.c
-fat_gay_man-@pieshop$ ./iloveyou
I Love You-fat_gay_man-@pieshop$
 
R

Robert Gamble

-fat_gay_man-@pieshop$ vi iloveyou.c

#include <stdio.h>

int main(void) {
printf("I Love You");
return 0;
}
:wq
-fat_gay_man-@pieshop$ cc -o iloveyou iloveyou.c
-fat_gay_man-@pieshop$ ./iloveyou
I Love You-fat_gay_man-@pieshop$

I'm not sure what you are trying to show here, have you also confused
printf() with puts()? puts() writes a newline character after the
given string, printf() does not. The original program to which Walter
objected used puts().

Robert Gamble
 
A

akarl

Robert said:
I'm not sure what you are trying to show here, have you also confused
printf() with puts()? puts() writes a newline character after the
given string, printf() does not. The original program to which Walter
objected used puts().

You're missing the point. The omission of a newline enables us to write
sentences with the output combined with the command line prompt ;-)
 
P

pete

akarl said:
You're missing the point.
The omission of a newline enables us to write
sentences with the output combined with the command line prompt ;-)

If a system requires the last line of a text stream
to be newline terminated, as a system may,
then the omission of a newline, means that there is no line of text.
 
M

Malcolm

Suzie said:
How can I say 'I love you.' in C?
If you want a sweet gift for a programming boyfriend, look up the obfuscated
C contest. (Google).

There are lots of ways of producing a program that prints the output "I love
you" in interesting ways.
For instance you could create a series of #defines to make the source code
into the shape of a heart.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,166
Messages
2,570,902
Members
47,442
Latest member
KevinLocki

Latest Threads

Top