Ubuntu 18.04 think C/C++ source code file is plain text

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
When I try to create a C/C++ source file
touch test.cpp
Usually it will generate a file which type is C source code file. But today I got a plain text file.
And I write a simple program in it like:
#include <stdio.h>
int main()
printf("hello");
Then I use G++ to compile it:
g++ test.cpp -o test
However, I got a sharedlib file instead of executable file.
And I can run the sharedlib file and get the correct ouput:
./test
hello
In the past, I can directly create a C++ source code file and this file type is easy to edit in vscode. But the plain text file is not comfortable for me.
So the two questions really bother me:
- why my Ubuntu can not recognize C/C++ source code file correctly?
- why I get a sharedlib file by using default g++ command?
ubuntu nautilus mime-types file-command
add a comment |Â
up vote
0
down vote
favorite
When I try to create a C/C++ source file
touch test.cpp
Usually it will generate a file which type is C source code file. But today I got a plain text file.
And I write a simple program in it like:
#include <stdio.h>
int main()
printf("hello");
Then I use G++ to compile it:
g++ test.cpp -o test
However, I got a sharedlib file instead of executable file.
And I can run the sharedlib file and get the correct ouput:
./test
hello
In the past, I can directly create a C++ source code file and this file type is easy to edit in vscode. But the plain text file is not comfortable for me.
So the two questions really bother me:
- why my Ubuntu can not recognize C/C++ source code file correctly?
- why I get a sharedlib file by using default g++ command?
ubuntu nautilus mime-types file-command
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
When I try to create a C/C++ source file
touch test.cpp
Usually it will generate a file which type is C source code file. But today I got a plain text file.
And I write a simple program in it like:
#include <stdio.h>
int main()
printf("hello");
Then I use G++ to compile it:
g++ test.cpp -o test
However, I got a sharedlib file instead of executable file.
And I can run the sharedlib file and get the correct ouput:
./test
hello
In the past, I can directly create a C++ source code file and this file type is easy to edit in vscode. But the plain text file is not comfortable for me.
So the two questions really bother me:
- why my Ubuntu can not recognize C/C++ source code file correctly?
- why I get a sharedlib file by using default g++ command?
ubuntu nautilus mime-types file-command
When I try to create a C/C++ source file
touch test.cpp
Usually it will generate a file which type is C source code file. But today I got a plain text file.
And I write a simple program in it like:
#include <stdio.h>
int main()
printf("hello");
Then I use G++ to compile it:
g++ test.cpp -o test
However, I got a sharedlib file instead of executable file.
And I can run the sharedlib file and get the correct ouput:
./test
hello
In the past, I can directly create a C++ source code file and this file type is easy to edit in vscode. But the plain text file is not comfortable for me.
So the two questions really bother me:
- why my Ubuntu can not recognize C/C++ source code file correctly?
- why I get a sharedlib file by using default g++ command?
ubuntu nautilus mime-types file-command
edited Jun 28 at 10:35
Kusalananda
101k13199312
101k13199312
asked Jun 28 at 10:08
pangbryant
1
1
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
0
down vote
The command touch test.cpp creates a plain text file in Ubuntu 18.04 by default as it should. Next try opening test.cpp in Gedit text editor and pasting the following code as you did:
#include <stdio.h>
int main()
printf("hello");
Save the file. Now look at the right side of the bottom panel in Gedit and you will see that the file type has changed to C++. Right-click test.cpp and select Properties and you will see that the Type has changed to C++ source code (text/x-c++src). You should have no problem running test.cpp which now has type C++ source code (text/x-c++src) in Visual Studio Code.
If you want to get an executable/x-sharedlib file (which has a lavender diamond-shaped icon with two gears in Ubuntu 18.04) instead of an application/x-sharedlib file, then you need to create a new project for the test.cpp source code in Visual Studio Code before running it.
Its type becomes c++ source code file. But when I edit it in VSCode, if I delete the#include <stdio.h>, and then I try to rewrite this code, the autocomplete doesn't have reaction. In the past, when I input#incl, the autocomplete will help me to finish#include
â pangbryant
Jun 28 at 10:42
That's an unexpected result because whenever you edit a C++ source code file in Visual Studio Code the autocomplete functionality should work properly, especially if you have already saved the C++ file at least once in Visual Studio Code.
â karel
Jun 28 at 10:48
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
The command touch test.cpp creates a plain text file in Ubuntu 18.04 by default as it should. Next try opening test.cpp in Gedit text editor and pasting the following code as you did:
#include <stdio.h>
int main()
printf("hello");
Save the file. Now look at the right side of the bottom panel in Gedit and you will see that the file type has changed to C++. Right-click test.cpp and select Properties and you will see that the Type has changed to C++ source code (text/x-c++src). You should have no problem running test.cpp which now has type C++ source code (text/x-c++src) in Visual Studio Code.
If you want to get an executable/x-sharedlib file (which has a lavender diamond-shaped icon with two gears in Ubuntu 18.04) instead of an application/x-sharedlib file, then you need to create a new project for the test.cpp source code in Visual Studio Code before running it.
Its type becomes c++ source code file. But when I edit it in VSCode, if I delete the#include <stdio.h>, and then I try to rewrite this code, the autocomplete doesn't have reaction. In the past, when I input#incl, the autocomplete will help me to finish#include
â pangbryant
Jun 28 at 10:42
That's an unexpected result because whenever you edit a C++ source code file in Visual Studio Code the autocomplete functionality should work properly, especially if you have already saved the C++ file at least once in Visual Studio Code.
â karel
Jun 28 at 10:48
add a comment |Â
up vote
0
down vote
The command touch test.cpp creates a plain text file in Ubuntu 18.04 by default as it should. Next try opening test.cpp in Gedit text editor and pasting the following code as you did:
#include <stdio.h>
int main()
printf("hello");
Save the file. Now look at the right side of the bottom panel in Gedit and you will see that the file type has changed to C++. Right-click test.cpp and select Properties and you will see that the Type has changed to C++ source code (text/x-c++src). You should have no problem running test.cpp which now has type C++ source code (text/x-c++src) in Visual Studio Code.
If you want to get an executable/x-sharedlib file (which has a lavender diamond-shaped icon with two gears in Ubuntu 18.04) instead of an application/x-sharedlib file, then you need to create a new project for the test.cpp source code in Visual Studio Code before running it.
Its type becomes c++ source code file. But when I edit it in VSCode, if I delete the#include <stdio.h>, and then I try to rewrite this code, the autocomplete doesn't have reaction. In the past, when I input#incl, the autocomplete will help me to finish#include
â pangbryant
Jun 28 at 10:42
That's an unexpected result because whenever you edit a C++ source code file in Visual Studio Code the autocomplete functionality should work properly, especially if you have already saved the C++ file at least once in Visual Studio Code.
â karel
Jun 28 at 10:48
add a comment |Â
up vote
0
down vote
up vote
0
down vote
The command touch test.cpp creates a plain text file in Ubuntu 18.04 by default as it should. Next try opening test.cpp in Gedit text editor and pasting the following code as you did:
#include <stdio.h>
int main()
printf("hello");
Save the file. Now look at the right side of the bottom panel in Gedit and you will see that the file type has changed to C++. Right-click test.cpp and select Properties and you will see that the Type has changed to C++ source code (text/x-c++src). You should have no problem running test.cpp which now has type C++ source code (text/x-c++src) in Visual Studio Code.
If you want to get an executable/x-sharedlib file (which has a lavender diamond-shaped icon with two gears in Ubuntu 18.04) instead of an application/x-sharedlib file, then you need to create a new project for the test.cpp source code in Visual Studio Code before running it.
The command touch test.cpp creates a plain text file in Ubuntu 18.04 by default as it should. Next try opening test.cpp in Gedit text editor and pasting the following code as you did:
#include <stdio.h>
int main()
printf("hello");
Save the file. Now look at the right side of the bottom panel in Gedit and you will see that the file type has changed to C++. Right-click test.cpp and select Properties and you will see that the Type has changed to C++ source code (text/x-c++src). You should have no problem running test.cpp which now has type C++ source code (text/x-c++src) in Visual Studio Code.
If you want to get an executable/x-sharedlib file (which has a lavender diamond-shaped icon with two gears in Ubuntu 18.04) instead of an application/x-sharedlib file, then you need to create a new project for the test.cpp source code in Visual Studio Code before running it.
edited Jun 28 at 11:09
answered Jun 28 at 10:28
karel
706817
706817
Its type becomes c++ source code file. But when I edit it in VSCode, if I delete the#include <stdio.h>, and then I try to rewrite this code, the autocomplete doesn't have reaction. In the past, when I input#incl, the autocomplete will help me to finish#include
â pangbryant
Jun 28 at 10:42
That's an unexpected result because whenever you edit a C++ source code file in Visual Studio Code the autocomplete functionality should work properly, especially if you have already saved the C++ file at least once in Visual Studio Code.
â karel
Jun 28 at 10:48
add a comment |Â
Its type becomes c++ source code file. But when I edit it in VSCode, if I delete the#include <stdio.h>, and then I try to rewrite this code, the autocomplete doesn't have reaction. In the past, when I input#incl, the autocomplete will help me to finish#include
â pangbryant
Jun 28 at 10:42
That's an unexpected result because whenever you edit a C++ source code file in Visual Studio Code the autocomplete functionality should work properly, especially if you have already saved the C++ file at least once in Visual Studio Code.
â karel
Jun 28 at 10:48
Its type becomes c++ source code file. But when I edit it in VSCode, if I delete the
#include <stdio.h> , and then I try to rewrite this code, the autocomplete doesn't have reaction. In the past, when I input #incl , the autocomplete will help me to finish #includeâ pangbryant
Jun 28 at 10:42
Its type becomes c++ source code file. But when I edit it in VSCode, if I delete the
#include <stdio.h> , and then I try to rewrite this code, the autocomplete doesn't have reaction. In the past, when I input #incl , the autocomplete will help me to finish #includeâ pangbryant
Jun 28 at 10:42
That's an unexpected result because whenever you edit a C++ source code file in Visual Studio Code the autocomplete functionality should work properly, especially if you have already saved the C++ file at least once in Visual Studio Code.
â karel
Jun 28 at 10:48
That's an unexpected result because whenever you edit a C++ source code file in Visual Studio Code the autocomplete functionality should work properly, especially if you have already saved the C++ file at least once in Visual Studio Code.
â karel
Jun 28 at 10:48
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f452399%2fubuntu-18-04-think-c-c-source-code-file-is-plain-text%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password