Basic Linux operating

Forced to turn Linux, I began to think that would be suited, in fact, better, a new name

This article talk about the basic operation, enough to make you happy to play the code, Baidu would like to fly overhead on their own, or find other great God (Friends of the chain)

[Multi-map] warning

First, there is no Dev C ++, the notebook had been ridiculed in the change of the name of the Windows text editor, became the only tool

This is basically the final form. Find a text editor in the lower left corner of the menu to open it. Click on the upper left corner "text editor" triangle numbers. Select Preferences.

Adjust the settings according to their own preferences. But the most important thing is that a plug-in.

Both are first opened, then closed Python that one, this time your text editor may occur following the terminal.

Terminal, or is the Chinese "terminal" word.

This would be a lot easier. However, some systems in text editor did not "terminal" this plugin, then you have to find all the applications from the terminal, and all operations are the same.

When playing the code words are no color, it can be at the bottom right "plain text" there instead choose "C ++", the keyword will appear in different colors.

Another approach is after you've played the first row include what is saved with the extension ".cpp", then it will automatically enter the C ++ mode.

Next, if you have a finished code. Now we need to compile and run.

First of all, Ctrl + S to save the file, note: the end is to be named with ".cpp", otherwise it is impossible to compile. To abc.cpp example.

In the terminal enter "g ++ abc.cpp" can be compiled. If no other messages appear, the compilation is successful, otherwise an error message will pop up, and the same as under Windows.

Note: Each time you modify the code to be re (Ctrl + S) to save, recompile.

After compiling your code it will be converted to "a.out" programs. In the terminal input "./a.out" to run. The "./" represents the current directory. (Later have to explain)

Note: Unlike Windows, the program runs can still continue to enter, so an infinite loop of code under Windows will show reading has not been completed traits.

In the end, press the ↑ ↓ keys to browse command history, so you do not have to keep entering the complete command.

As in most cases we are compiling -> Run -> change the code -> compile -> Run -> ..., so compile and run the command double-click ↑ came out (multi-tone, you will be skilled)

In the end, press Tab to auto-complete words as you need "g ++ abc.cpp", then you only need to enter "g ++ ab", then press Tab, the entire instruction will auto-complete.

However, when you take too many files with the same name, Tab completion does not know to help you make that one, then you. . . . . . (Promptly deleted files, or to manually completion)

Other terminal command might be used:

  ls lists all files in the current directory.

  Which is blue folder.

  cd folder name: enter the folder directory. Because all of your operations so you only have to enter the folder and then move inside in the current directory.

  cd: go back one level.

  rm file name: delete the specified file

  mkdir Folder name: Create a folder

  kill -9 -1: end all the processes, corresponding to reboot to save the file. For the end of the program crash. (I will not try again to give you the screenshot)

  However, if your text editor does not die and you want to end the current program, press (Ctrl + Z) can be, for! This thing is not the end of the reading, but the end of the program!

  Some may also compiled a use operation.

  g ++ abc.cpp -o b.out -------- compiled abc.cpp and compile the program was renamed b.out (default is a.out)

  g ++ abc.cpp -g -------- compile and prepare for the gdb debugger. (Best not to use, explain at the end of the text)

Main event: The next talk again to shoot under Linux

  Data generator standard process, error codes and their freopen completely intact, while there is little change metronome.

 1 #include<cstdio>
 2 #include<cstdlib>
 3 using namespace std;
 4 
 5 int main()
 6 {
 7     int i;
 8     for (i=1;i<=1000;i++)
 9         {
10             system("./make");
11             system("./ab1");
12             system("./ab2");
13             printf("%d : ",i);
14             if (system("diff ab1.out ab2.out"))
15                 {
16                     printf("WA\n");
17                     return 0;
18                 }
19             else printf("AC\n");
20         }
21     return 0;
22 }
To beat code

  Nothing more than a function is called when the system is running a "./" represents the current directory, and file comparison cd into a diff only.

  diff and cd under Windows as the same for the different false is true, no difference.

  Then run to take control on it.

  Even better, unlike Windows casual Output "is comparing" what a bunch, unless the file under Linux different, diff nothing will be output.

  It will only obediently output code you write "AC" or something, watching the odd cool.

To take this over.

Next content, need to be cautious reading: metamorphosis gdb debugging

Why is it best not to look at it? Because it handy, may make you become dependent, weaken your intuition, reduce your ability to tune code.

Support the use of various competitions, and then when you're really stressed out. Anyway, I was always afraid to use it.

The reminder reminder finished, the next treasure myself, I began to talk about it.

Followed by the need -g, such as g ++ abc.cpp -g compile gdb debugging time

Before running the program name with gdb as gdb ./a.out

Then it will pop up a lot of stuff like copyright

The next instruction is used:

r: start running the program, different from c.

b sth: set breakpoints, each time when the program runs to the breakpoint will be suspended. sth can be a digital representation of the first few lines, it may also be a function name, equivalent to the first line of the function declaration.

cl sth: clear breakpoints, and b is identical. The first will be cleared only when the input cl without parameters.

c: to suspend the program continues to run (to the end or the next breakpoint), it can not be used to start a program, so you need to remember r.

p sth: outputting the content. system comes sth may be variable, the array (not too large), the structure and the vector, priority_queue, map data such structures.

disp sth: p and the same, but disp outputs corresponding contents each time the program is paused. I do not know disp, large Church will teach me.

wa sth: disp and the same, but wa pauses the program at each corresponding variable changes, no break.

cond sth (condition): cond is for the breakpoint, sth is the breakpoint number, provided that the C ++ statements, cond make the program runs to the breakpoint when the judge, the condition is suspended, otherwise continue. As cond 1 i == 5

Press (Ctrl + Z) to exit gdb mode. The changes to your code that still need to re-compile with the -g.

Also compiled with the -g default is a.out, you can still use the normal execution ./a.out without entering gdb mode.

There are some very magical instruction, no longer speak, this in itself is not recommended. I will not, will complement the great God.

When I did not change the system, it took more than a day to explore their own Internet search +, I am sure not all listed, waiting for you to add.

Try to explore, is it not a process fun of it?

Guess you like

Origin www.cnblogs.com/hzoi-DeepinC/p/11015800.html