'Cannot open source file "stdio.h" in Visual Studio Code

I'm new to C and this is my first project using visual studio. I have #include <stdio.h> in the first line of the code but there is an error "cannot open source file "stdio.h" C/C++ (1696)". I have installed the Microsoft C/C++ extension. I am happy to clarify anything. Thank you!



Solution 1:[1]

Note:

Be aware that VSCode is simply an editor. With some extensions installed, it may help you code "faster & easier".

The C/C++ extension that I use


Solution:

But in order for you to compile the code it is less beginner friendly than IDEs like CodeBlocks.

The way I do it is by going to :

  • Terminal > New terminal
  • cd "the_directory_in_which_the_file.c_exists" (don't forget the double quotes)
  • gcc "file.c"
  • ./a.out (./a.exe on Windows)

Example: Hello Stackoverflow !


Just in case:

  • if gcc (the compiler in this case) is not installed, then you can quickly do so by following this article's steps if you use Windows, or this one if you are on Linux.

Solution 2:[2]

As @oh_my_lawdy commented, you don't really need regex here. However, if you want to use it then the issue with your code is that re.search() returns a match object. For such objects even the value of the expression

re.search(".+?(?=-)", txt1) == re.search(".+?(?=-)", txt1)

(with the same string txt1 on both sides) is False. What you should compare instead are the actual substrings matching the pattern. These can be obtained using

re.search(".+?(?=-)", txt1).group(0)

More precisely, this returns the first match group, but this is the only group in this case. In effect your code can be modified as follows:

txt1 = "ap1-tempora1yu"
txt2 = "ap1-gt4"
if re.search(".+?(?=-)", txt1).group(0) == re.search(".+?(?=-)", txt2).group(0):
    print("found")
else:
    print("not found")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2