A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Error: Invalid escape sequence in C | Common C program Errors
Q:

Error: Invalid escape sequence in C | Common C program Errors

0

Error: Invalid escape sequence in C | Common C program Errors

Sometimes, while writing Escape Sequences in C program, we mistakenly typed an invalid escape sequence, which does not give any error but does not give the expected result.

For example, if we want to print a "new line" between two words in a text and mistakenly typed \m instead of \n.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Consider the program:

#include <stdio.h>

int main(void) {
	
	printf("Hello world\mHow are you?");
	
	return 0;
}

Output

    Hello worldmHow are you?

We wanted to print "Hello world" and "How are you?" in separate lines but there is an invalid escape sequence \m. Thus, the result is "Hello worldmHow are you?".

How to fix "Invalid escape sequence in C" error

To fix this and such errors, you should know about all escape sequences and use them properly.

Read: Escape sequences in C

Correct code

#include <stdio.h>

int main(void) {
	
	printf("Hello world\nHow are you?");
	
	return 0;
}

Output

    Hello world
    How are you?

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now