-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNotes.txt
272 lines (199 loc) · 9.34 KB
/
Notes.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
Chapter 3 - Basic Concepts
1. Compoud types
A compound types is a type that is composed of other types. (The C language uses the term derived type.). The keywords struct and class identify as compound types.
C++ requires use of either keyword in the definition of the compound types. ( both struct , and class keyword are valid in c++)
//C style
struct Transaction {
int acct; // account
chat type; // thpe c credit d debit
double amount; //transaction amount
}
Forward declaration ;
struct Transaction; // Forward declaration , it informs the compiler that the type is a valid compound type without defining the type.
//C++ doesn't require "STRUCT" keyword in prototypes or memory allocations
C++ //
void enter(Transaction * );
void display(const Transaction*);
int main(){
Transaction tr;
}
C Version
void enter(struct Transaction *);
void display(const struct Transaction*);
int main(){
struct Transaction tr;
}
----------------
"auto" keyword -- declares a variable or object and deduces its type from the type of its initializer.
auto x = 4; // x is of type int
auto x = 3.4 // x is type of double
------------
you can access struct pointer variable using -> operator
void display ( const Transaction *tr){
cout << "account" >> tr->acct << endl;
}
---
C++ has one definition rule, which means forward declarations or function prototypes can have only one definition, or compiler will throw an compiler error. ( Look chapter3 onedefinition rule explain)
Default parameter value - ( look chapter3 - defaultparam.cpp)
-------------- HOW TO RUN A PROGRAM IN C++ AND KOTLIN Command prompt ---------------------
C++
====
To compile:
> g++ sourceFile.cpp -o outputFilename
To run:
> ./outputFilename
While compiling multiple Cpp and header files, remember one definition rule.
If main has included impl.cpp file then no need to add it while compiling that file.
i.e. g++ Node.cpp NodeImpl.cpp NodeMain.cpp
in this case, NodeMain.cpp has included header file NodeImpl thus no need to compile that.
it should be, "g++ Node.cpp NodeMain.cpp -o app" only.
Kotlin
======
To compile:
> kotlinc hello.kt -include-runtime -d hello.jar
To run:
> java -jar hello.jar
=================
links of useful commands of gcc - https://gcc.gnu.org/onlinedocs/gcc-3.2/gcc/Overall-Options.html#Overall%20Options
=================
Alt+shift+F = Format code on Windows in VSC.
=================
echo -e ${PATH//:/\\n} --> to print all paths with newline in Windows
which g++ --> To find set path of a particular command
Key bindings track:
Firefox
Alt + <-- / --> || To go backward in visted pages history - firefox
Ctrl + tab -> switch between tabs
Ctrl + L - jump to address bar -- Ctrl + E - search
VSC
Alt + <-- / --> || jump between opened files - more like going back ,
Ctrl+tab for jump between opened files, add shift if wanna go in different order from last to first
Ctrl + ` = open terminal , Ctrl + shift + ` --> open new terminal
Ctrl+ shift+ p -> Command pallete
Ctrl + P -> search file names.
Ctrl + shift + k , Ctrl+x -> delete line
Ctrl + shift + v - paste code without format.
Ctrl + j -> opens terminal
Ctrl + shift + E -> opens editor files explorer
Ctrl + L -> select a line
Ctrl + g -> jump to a specific line number
Ctrl + D -> find duplicate and replace all occurances
Alt + up/down -> move a line
Ctrl + 1 (number) -> switch between split editor windows
shift + c + down/up arrow (Column selection - changed myself) to select columns and remove space for
To use shift+C -> Shift+c -> keep holding shift n then up and down arrow.
Notes: Shift +C will enter into column mode.. then use Shift+arrow key for selection. Press shift+c to exit that column selection mode.
Ctrl+ shift + arrow -> for selecting one word and then ctrl + ALT + arrow up/down to keep selection there and replace many occurances at the same indentation
Alt + shift + up/down to duplicate a line down or up.
Alt + shift + forth arrow will select a block of code such as a function with curly braces
important - placement of cursor shouldn't be next to a word, otherwise word selection will trigger.
if next to a word, then keep pressing to increase the area of selection.
Alt + T -> Toggle Terminal -> focus on Terminal in panel
Ctrl+shift+` opens a new terminal
Ctrl + alt + t -> openInTerminal -> opens a terminal with current directory open
Ctrl + j -> opens a panel with output/terminal
Shift + K -> kill the active terminal
workbench.action.terminal terminal.focusAtIndex1 -> Added alt+i
F12 -> definition, alt+f12 - peek definition
Ctrl + q -> query to open search, explorer and many other options
Ctrl+shift+ M -> Terminal - PROBLEMS... problems to check effors and jump to those lines.
Ctrl + shift + u -> terminal - OUTPUT
Ctrl + , -> settings
Ctrl + shift + L -> editor.action.selectHighlights -> selects all occurances n ability to edit or remove..
Ctrl + D - allows you to select in order, but Ctrl+shift+L does select all occurances
Ctrl + D can also be used to select current word without using ctrl+shift+arrow
Ctrl+ c -> without any selection just at the start of a line, will copy the entire line and you can paste, just like ctrl +x - cuts without selection
alternatives - Alt+shift+arrow up or down
Ctrl + l -> selects the entire line and then () or "" to wrap
Notes on make files
To run make file = make -f `makeFileName`
-> Interactively run (When c++ program asks for an input) a program use this command:
Cu Mx compile make -f `makeFileName`
if done with Mx, doesn't work.
-> Other useful commands
Cx d -> browse through directory
Cx Cf -> files
Cx Cs -> save file
Cx d :/ to go to home directory in case to change .emacs files.
Cx d d:/ to get to other drive directory
Mx recentf-open-files - to open recently opened files.
Mx recompile to rerun the code in compilation mode.
Navigate through buffers Cx Cb -> possible another way to check opened files in emacs and navigate through it.
-> gdb mode
Mx Gdb
watch var -> to watch
p var -> to print
b 11 -> break point at that line number
run -> run the program.
c - continue
s -> step through
display var
p *arr@[3] size to print an array
--To save and restore breakpoints in gdb
save-breakpoints fileName
source fileName
-> Copy line
C space -> turn on selection
Get to end or start of a line by C a / C e
then CSpace
C e / C a either side you want selection to go
M w to copy the region
C y yank (paste)
-> Buffer
Cx Cb -> buffers
jump between opened buffers - Cx left/right arrow.
-> Comment a block of code
Mx comment-region
Mx uncomment-region
-> Editor zoom / unzoom
Cx + C+ zoom, C- unzoom
-> creating directory
Cx d -> move to directory
at the end in empty area, + to add a new directory
m - > mark a file
Shift + c ->copy
Shift + d ->delete
-> Cu C-space OR CxCxCg to get back again
CxCxCg does not change the mark ring.
Cx Cspace- jumps between multiple files, using mark ring.
Cx Cx swaps point and mark and activtes the region. Cg then deactives the region.
-> increment number lines
Cx space to select column
Mx rectangle-number-lines to add 1.. n numbers in column
Cx space to select column then
Mx string-rectangle to add any character you want.
----> string-rectangle replace that function with C t -> will run the string-rectangle function.
USING macro to achieve the same
F3 or Cx ( - record macro
navigate to each ( (open bracket) and insert 1 or desired number
F4 or Cx ) to stop recording macro
Cx e -> to RUN the macro.
Cx r N -> also single command that can add 1 ... n based on selection. Basically same as rectangle-number-lines but with one single command
-> Rectangle charater replace Cc r
-> delete current line -> C + Shift + Del/ backspace.
-> Gdb tutorial for emacs - onestepcode.com/debugging-c-gdb-emacs
-> Compilation
Cx ` - for next Error, Mg-n Mg-p for next and previous error from compilation mode.
set global key for compile recompile to f5 f6
jump to first error (setq compilation-auto-jump-to-first-error t)
-> Close current window Cx-0
Open current file in another window in dired mode - Co
-> Split screen vertically Cx 2, horizontally Cx 3
/////////////// EMACS settings when setting up.
(message "%s" user-init-file) // gives you current file path for .emacs/init file that emacs look for
(message "%s" user-emacs-directory) //gives you dir of emacs.
(load-file "D:/emacs_settings/.emacs")
========= Add following in .emacs file to set custom location for .emads.d dir and load custom .emacs file. ========
(setq user-emacs-directory "D:/emacs_settings/.emacs.d/")
(setq package-user-dir (expand-file-name "elpa/" user-emacs-directory))
;; Melpa enabled
(require 'package) ; Ensure package.el is loaded
(setq package-archives
'(("melpa" . "https://melpa.org/packages/")
("gnu" . "https://elpa.gnu.org/packages/")
("nongnu" . "https://elpa.nongnu.org/nongnu/")))
(package-initialize)
(setq user-init-file "D:/emacs_settings/.emacs")
(setq default-directory "D:/")
(load user-init-file)
//////////////////////////////////////// END of .emacs file to set custom file paths for .emacs file and .emads.d directory