How Do I Use Raw Text?

I’d like to print raw text to the screen. How I would do so in Python would look like this:

print('''
hello
my name
is
austin''')

The above text would print the following to the console:

hello
my name
is
austin

How would I do this in C?

You just need to use printf

#include <stdio.h>

int main() {
    printf("hello\n"
           "my name\n"
           "is\n"
           "austin\n");
    return 0;
}
2 Likes

@WindLother I am getting two errors:

Preprocessor directive expected

on #include <stdio.h>

and

The name 'printf' does not exist in the current context

on

    printf("hello\n"
           "my name\n"
           "is\n"
           "austin\n");
    return 0;

Are you sure you are using a C template?

@WindLother I am kind of using a C template. It best fit for what I’m running. I should’ve mentioned this earlier but it is cs file. I’m using COSMOS OS.

If you’re using a .cs file, then you’re dealing with C# (which is completely different from C). COSMOS OS uses C#.

To make the same thing in C#:

using System;

namespace WhateverNamespace
{
    public class Program
    {
        public static void Main()
        {
            Console.WriteLine(@"hello
my name
is
austin");
        }
    }
}
1 Like

Ahhhhhh! That makes sense! My bad!
I’ll try the code rn.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.