Write a love letter in C programming language

Love letter in C

Love letter in CIf you are a geek just like me and you want to impress somebody with a love letter and you don’t have an idea how to do it then you have come to the correct place.  Trust me there is no better way than to express your love for somebody better than with words. You can say something nice to her, you can take her to a romantic date, you can kiss her but that won’t last. A love letter is for eternity. It will be cherished forever and will always bring a smile to her face. I came up with an idea and the code is very simple which I will be sharing with you in a few moments. This worked amazingly for me and this post is dedicated to her. First of all you should know

What should be there in a love letter?

1. It should express your love and feelings for him/her.

2. It should be funny and remind him/her of the lovely times you had together.

3. Most importantly it should be innovative.

I will not write anything about the first two points. You will find hundreds of posts about how to write a love letter but this post is all about the third point. The love letter I wrote was made in C which made it innovative and the best part is the code is very simple to understand. You can just edit a line and make your own personalized letter or you can even modify my idea and come up with a new idea all together. But then do not forget to write your idea in the comments section.

Show the C code already:


#include<stdio.h>
#include<string.h>
void main() {
 //change the string to the words u want to say
 char *arr = "I just wanted to show u how much I missed u but didn't know how I can show you. And finally I came up with this idea when you went for dinner. I missed u a loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooot :-*";
 int i = 0;
 printf("Type something:\n");
 while(i < strlen(arr)) {
 getch();
 printf("%c", arr[i++]);
 }
 getch();
}

This was the original message I wrote for her. Change it to the message you have for the girl/guy you want to impress.

Explain the love letter to me:

The letter is very simple. What it does is it has a string (arr) which contains the message you want to say. The integer (i) is used to print the ‘i’th character of the string (arr) till the value of ‘i’ is less than the length of the string. getch() takes in a character and doesn’t display anything and plays an important role in the program. Compile the program and send her the .exe file and wait for wonders to happen.

Hopefully you enjoyed reading this tutorial. If you have any other idea of writing technical love letters share it with me. Also if you have tried this particular technique I would love to hear the reaction you received. Use the comments section below. Thank you and visit www.intechgrity.com for more interesting tutorials and posts.

17 comments

  1. virneto

    Boy, I loved this one!!!
    Must say this is a rocking awesome idea!!
    I’ll do it right away. And thanks for making the C simple.

    Ps.: I couldn’t help noticing…
    I can see how lucky you got when you say “send her the .exe file and wait for wonders to happen”
    😉 😉 😉
    Great post!
    Cheers to you!!!
    Virneto

  2. neha sachdev

    i m sure that gal fell head over heels in love with you …. <3

  3. someone

    How do I get this to work on Linux? There is no getch() function I guess, or at least not in the included header files, gcc says: undefined reference to `getch’
    I tried to inlcude conio.h as someone suggested in some forum but gcc doesn’t know that header file.
    I tried getchar() instead which works but does not the same thing as getch() does I guess. (You don’t want the input being shown on the terminal I suppose?)

    Any help would be appreciated, I’m not very good at programming obviously :/

    Maybe would be nice if you could also just send the code, if he or she is able to use a compiler 🙂
    But then the message should be encrypted somehow, of course, and being decrypted when you start the program…
    (I dont know if that makes any sense at all 😉

  4. Deanne

    Would love you know how to say. I love you Sid in C++
    My partner works as a programmer and writes in c++. It is alien to me but I do try and take interest in what he does for a living.Could any one help me with them four words and convert them into c++ CODE please. thank you Dee xde

    • arnab Post author

      Follow the simple steps:
      1. Replace the string in the program with yours.(5th line in the program between the ” “)
      2. Download a C compiler and compile the code. In case you don’t know to do that, google it up.
      3. Send him the exe file that will be generated and wait for his response.
      Cheers 🙂

    • arnab Post author

      This is a good idea. As this is a command line program you will not be able to add an image. I’ll try to write another post with an option of adding an image. Thanks for the idea.

  5. LuciaKim

    Hey I copied and pasted this code for practice but this does not work with message “Checking for existence: C:\Users\User\Desktop\Coding\Love you.exe” I am beginner of coding so can I ask you is there anything wrong?? ;( Thank you!!!

  6. Maxxers

    Hi, I’m not a programmer but I wanted to do this for my boyfriend. I tried your code on codechef.com but it seems not to be working, but it says there’s a compilation error:

    prog.cpp:3:11: error: ‘::main’ must return ‘int’
    void main() {
    ^
    prog.cpp: In function ‘int main()’:
    prog.cpp:5:14: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
    char *arr = “I just wanted to show u how much I missed u but didn’t know how I can show you. And finally I came up with this idea when you went for dinner. I missed u a loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooot :-*”;
    ^
    prog.cpp:9:8: error: ‘getch’ was not declared in this scope
    getch();
    ^
    prog.cpp:12:8: error: ‘getch’ was not declared in this scope
    getch();
    ^

    I obviously have no idea what this means, could you please help me? (:

  7. arnab Post author

    @Maxxers Codechef will not give you the exe file so it would be of no use. What you can do instead is download a C compiler and compile the code there. Refer to one of the previous comments for how to do it.

Comments are closed.