Remove KDevelop files and add 2-3 progress

This commit is contained in:
caskd 2019-11-10 02:02:22 +01:00
parent e794208535
commit 16788f80b1
No known key found for this signature in database
GPG Key ID: 79DB21404E300A27
8 changed files with 91 additions and 298 deletions

7
.gitignore vendored
View File

@ -1,2 +1,5 @@
build/
*~
CMakeCache.txt
CMakeFiles
cmake_install.cmake
learningc
Makefile

View File

@ -1,292 +0,0 @@
[Buildset]
BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x12\x00L\x00e\x00a\x00r\x00n\x00i\x00n\x00g\x00C)
[CMake]
Build Directory Count=1
Current Build Directory Index-Host System=0
[CMake][CMake Build Directory 0]
Build Directory Path=/home/caskd/Projects/LearningC/build
Build Type=Debug
CMake Binary=/usr/bin/cmake
CMake Executable=/usr/bin/cmake
Environment Profile=
Extra Arguments=
Install Directory=
Runtime=Host System
[Clazy]
checks=level2
[Cppcheck]
checkPerformance=true
checkPortability=true
checkStyle=true
[Filters]
size=43
[Filters][0]
inclusive=0
pattern=.*
targets=3
[Filters][1]
inclusive=1
pattern=.gitignore
targets=1
[Filters][10]
inclusive=1
pattern=.clang-format
targets=1
[Filters][11]
inclusive=1
pattern=.circleci
targets=2
[Filters][12]
inclusive=0
pattern=.git
targets=2
[Filters][13]
inclusive=0
pattern=CVS
targets=2
[Filters][14]
inclusive=0
pattern=.svn
targets=2
[Filters][15]
inclusive=0
pattern=_svn
targets=2
[Filters][16]
inclusive=0
pattern=SCCS
targets=2
[Filters][17]
inclusive=0
pattern=_darcs
targets=2
[Filters][18]
inclusive=0
pattern=.hg
targets=2
[Filters][19]
inclusive=0
pattern=.bzr
targets=2
[Filters][2]
inclusive=1
pattern=.gitmodules
targets=1
[Filters][20]
inclusive=0
pattern=__pycache__
targets=2
[Filters][21]
inclusive=0
pattern=*.o
targets=1
[Filters][22]
inclusive=0
pattern=*.a
targets=1
[Filters][23]
inclusive=0
pattern=*.so
targets=1
[Filters][24]
inclusive=0
pattern=*.so.*
targets=1
[Filters][25]
inclusive=0
pattern=*.obj
targets=1
[Filters][26]
inclusive=0
pattern=*.lib
targets=1
[Filters][27]
inclusive=0
pattern=*.dll
targets=1
[Filters][28]
inclusive=0
pattern=*.exp
targets=1
[Filters][29]
inclusive=0
pattern=*.pdb
targets=1
[Filters][3]
inclusive=1
pattern=.pre-commit-config.yaml
targets=1
[Filters][30]
inclusive=0
pattern=moc_*.cpp
targets=1
[Filters][31]
inclusive=0
pattern=*.moc
targets=1
[Filters][32]
inclusive=0
pattern=ui_*.h
targets=1
[Filters][33]
inclusive=0
pattern=*.qmlc
targets=1
[Filters][34]
inclusive=0
pattern=qrc_*.cpp
targets=1
[Filters][35]
inclusive=0
pattern=*~
targets=1
[Filters][36]
inclusive=0
pattern=*.orig
targets=1
[Filters][37]
inclusive=0
pattern=.*.kate-swp
targets=1
[Filters][38]
inclusive=0
pattern=.*.swp
targets=1
[Filters][39]
inclusive=0
pattern=*.pyc
targets=1
[Filters][4]
inclusive=1
pattern=.gitlab-ci.yml
targets=1
[Filters][40]
inclusive=0
pattern=*.pyo
targets=1
[Filters][41]
inclusive=0
pattern=/learningc
targets=1
[Filters][42]
inclusive=0
pattern=/build/learningc
targets=1
[Filters][5]
inclusive=1
pattern=.travis.yml
targets=1
[Filters][6]
inclusive=1
pattern=.editorconfig
targets=1
[Filters][7]
inclusive=1
pattern=.pep8
targets=1
[Filters][8]
inclusive=1
pattern=.prettierignore
targets=1
[Filters][9]
inclusive=1
pattern=.prettierrc*
targets=1
[Launch]
Launch Configurations=Launch Configuration 0
[Launch][Launch Configuration 0]
Configured Launch Modes=execute
Configured Launchers=nativeAppLauncher
Name=main
Type=Native Application
[Launch][Launch Configuration 0][Data]
Arguments=
Break on Start=false
Debugger Shell=
Dependencies=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x00)
Dependency Action=Nothing
Display Demangle Names=true
Display Static Members=false
EnvironmentGroup=
Executable=file:///home/caskd/Projects/LearningC
External Terminal=konsole --noclose --workdir %workdir -e %exe
GDB Path=
LLDB Arguments=
LLDB Config Script=
LLDB Environment=
LLDB Executable=
LLDB Inherit System Env=true
LLDB Remote Debugging=false
LLDB Remote Path=
LLDB Remote Server=
Project Target=LearningC,learningc
Remote GDB Config Script=
Remote GDB Run Script=
Remote GDB Shell Script=
Start With=ApplicationOutput
Use External Terminal=false
Working Directory=
isExecutable=false
[Project]
VersionControlSupport=kdevgit
[SourceFormatter]
text/x-c++hdr=kdevcustomscript||GNU_indent_GNU
text/x-c++src=kdevcustomscript||GNU_indent_GNU
text/x-chdr=kdevcustomscript||GNU_indent_GNU
text/x-csharp=kdevcustomscript||GNU_indent_GNU
text/x-csrc=kdevcustomscript||GNU_indent_GNU
text/x-java=kdevcustomscript||GNU_indent_GNU
text/x-objcsrc=kdevcustomscript||GNU_indent_GNU

View File

@ -3,8 +3,9 @@ cmake_minimum_required(VERSION 3.0)
project(learningc LANGUAGES C)
set(CHAPTER 2)
set(EXERCISE 1)
set(EXERCISE 3)
add_executable(learningc chapters/${CHAPTER}/exercises/${EXERCISE}.c)
target_link_libraries(learningc m) # Required for 2-3
install(TARGETS learningc RUNTIME DESTINATION bin)

View File

@ -1,3 +0,0 @@
[Project]
Name=LearningC
Manager=KDevCMakeManager

13
chapters/2/exercises/2.c Normal file
View File

@ -0,0 +1,13 @@
#include <stdio.h>
#include <limits.h>
#include "shared/functions.h"
#include "shared/functions/getlines.c"
#define MAXLINE 1024
int main() {
char r[MAXLINE];
while (getlines(r, MAXLINE) != EOF) {
printf("%s", r);
}
return 0;
}

46
chapters/2/exercises/3.c Normal file
View File

@ -0,0 +1,46 @@
#include <stdio.h>
#include <math.h>
#include "shared/functions.h"
#include "shared/functions/getlines.c"
#define MAXLINE 1024
int htoi(char s[], int l);
int main() {
char line[MAXLINE];
int out, len;
while ((len = getlines(line,MAXLINE)) != EOF) {
out = htoi(line,len);
}
printf("Result: %i\n", out);
return 0;
}
int htoi(char s[], int l) {
int num = 0, i, e;
for (i = l-1,e = 0; s[i] != 'x' && s[i] != 'X' && e <= 8; i--, e++) {
int c = 0;
switch (s[i]) {
case 'F': case 'f': c++;
case 'E': case 'e': c++;
case 'D': case 'd': c++;
case 'C': case 'c': c++;
case 'B': case 'b': c++;
case 'A': case 'a': c++;
case '9': c++;
case '8': c++;
case '7': c++;
case '6': c++;
case '5': c++;
case '4': c++;
case '3': c++;
case '2': c++;
case '1': c++;
default: break;
}
int mul = 1;
if (e != 0) {
mul = pow(16,e);
}
num = num + (mul * c);
}
return num;
}

View File

@ -0,0 +1 @@
int getlines(char s[], int lim);

View File

@ -0,0 +1,24 @@
int getlines(char s[], int lim) {
int i, c;
for (i = 0;i < lim-1;) {
if ((c = getchar()) != '\n') {
if (c != EOF) {
s[i++] = c;
} else {break;}
} else {break;}
}
if (c == EOF) {
s[i] = '\0';
return EOF;
} else if (c == '\n') {
if (i < lim-1) {
s[i] = c;
s[i+1] = '\0';
} else {
s[lim-1] = '\0';
}
} else {
s[i] = '\0';
}
return i;
}