For everything that's not in any way related to PureBasic. General chat etc...
codemaniac
Enthusiast
Posts: 289 Joined: Mon Apr 02, 2007 7:22 am
Location: Finland
Post
by codemaniac » Thu Apr 05, 2007 7:56 pm
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
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
Posts: 681 Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:
Post
by KarLKoX » Thu Apr 05, 2007 8:00 pm
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>";
Tipperton
Addict
Posts: 1286 Joined: Thu Jun 19, 2003 7:55 pm
Post
by Tipperton » Thu Apr 05, 2007 8:22 pm
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
Posts: 289 Joined: Mon Apr 02, 2007 7:22 am
Location: Finland
Post
by codemaniac » Thu Apr 05, 2007 8:29 pm
Thanks!
Cute?
KarLKoX
Enthusiast
Posts: 681 Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:
Post
by KarLKoX » Thu Apr 05, 2007 10:29 pm
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).
Tipperton
Addict
Posts: 1286 Joined: Thu Jun 19, 2003 7:55 pm
Post
by Tipperton » Fri Apr 06, 2007 12:04 am
Hmm.... back when I programed in C durring the DOS days, I recall doing something like this:
and it worked, the output was:
Hello
World!
But if just the \ works, great! That's one less character to type!
thefool
Always Here
Posts: 5875 Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark
Post
by thefool » Fri Apr 06, 2007 12:07 am
Tipperton wrote: Hmm.... back when I programed in C durring the DOS days, I recall doing something like this:
and it worked, the output was:
Hello
World!
But if just the \ works, great! That's one less character to type!
yes as he said, that is for string functions. The \ is for the lexer