Need some help with C

For everything that's not in any way related to PureBasic. General chat etc...
codemaniac
Enthusiast
Enthusiast
Posts: 289
Joined: Mon Apr 02, 2007 7:22 am
Location: Finland

Need some help with C

Post by codemaniac »

Hello!

Does anybody know if I can have a code block as a char in C? Maybe not exactly a char, probably tchar or something else, I don't know, because I am just starting out with C :oops:

The code block would be something similar to this:
<html>
<head>
<title>My Cool Website</title>
</head>
<body>
<p>Welcome to my cool website!</p>
</body>
</html>
Thanks!
Cute?
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Post by KarLKoX »

Code: Select all

const char foo[] = "<html><br>\
                       <head><br>\
                       <title>My Cool Website</title><br>\
                       </head><br>\
                       <body><br>\
                       <p>Welcome to my cool website!</p><br>\
                       </body><br>\
                       </html>";
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
Tipperton
Addict
Addict
Posts: 1286
Joined: Thu Jun 19, 2003 7:55 pm

Post by Tipperton »

Don't you need \n instead of just \ or is that a C++ thing?

Like this:

Code: Select all

const char foo[] = "<html><br>\n
                       <head><br>\n
                       <title>My Cool Website</title><br>\n
                       </head><br>\n
                       <body><br>\n
                       <p>Welcome to my cool website!</p><br>\n
                       </body><br>\n
                       </html>";
codemaniac
Enthusiast
Enthusiast
Posts: 289
Joined: Mon Apr 02, 2007 7:22 am
Location: Finland

Post by codemaniac »

Thanks!
Cute?
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Post by KarLKoX »

Tipperton wrote:Don't you need \n instead of just \ or is that a C++ thing?

Like this:

Code: Select all

const char foo[] = "<html><br>\n
                       <head><br>\n
                       <title>My Cool Website</title><br>\n
                       </head><br>\n
                       <body><br>\n
                       <p>Welcome to my cool website!</p><br>\n
                       </body><br>\n
                       </html>";
No, "\n" is only interpreted by functions like print, scanf ... where the '\' char is interpreted by the compiler (the lexer to be more precise).
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
Tipperton
Addict
Addict
Posts: 1286
Joined: Thu Jun 19, 2003 7:55 pm

Post by Tipperton »

Hmm.... back when I programed in C durring the DOS days, I recall doing something like this:

Code: Select all

fputs(stdout, "Hello\nWorld!");
and it worked, the output was:
Hello
World!
But if just the \ works, great! That's one less character to type! :mrgreen:
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

Tipperton wrote:Hmm.... back when I programed in C durring the DOS days, I recall doing something like this:

Code: Select all

fputs(stdout, "Hello\nWorld!");
and it worked, the output was:
Hello
World!
But if just the \ works, great! That's one less character to type! :mrgreen:
yes as he said, that is for string functions. The \ is for the lexer :)
Post Reply