diff --git a/.kdev4/LearningC.kdev4 b/.kdev4/LearningC.kdev4 index d3e17e6..39e3f98 100644 --- a/.kdev4/LearningC.kdev4 +++ b/.kdev4/LearningC.kdev4 @@ -15,5 +15,28 @@ Extra Arguments= Install Directory= Runtime=Host System +[Cppcheck] +checkPerformance=true +checkPortability=true +checkStyle=true + +[Launch] +Launch Configurations=Launch Configuration 0 + +[Launch][Launch Configuration 0] +Configured Launch Modes=execute +Configured Launchers=nativeAppLauncher +Name=New Compiled Binary Launcher +Type=Native Application + [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 diff --git a/main b/main deleted file mode 100755 index 48241d1..0000000 Binary files a/main and /dev/null differ diff --git a/main.c b/main.c index e269483..8c86e66 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,6 @@ #include +#include +#include // // PART OF 1-5, 1-15 // #define LOWER 0 @@ -8,9 +10,11 @@ // // PART OF 1-15 // float convert2cels(int fahr); -// // PART OF 1-16, 1-17 -// #define MAXLINE 1000 +// // PART OF 1-16, 1-17, 1-18, 1-19, 1-20 +#define MAXLINE 1000 // int getlines(char line[], int maxline); +int detab(char s[],int lim, int col); +// void reverse(char s[MAXLINE], char d[strlen(s)]); // void copy(char to[], char from[]); int main() { @@ -191,16 +195,34 @@ int main() { // } // } // } -// printf("\"%s\"\n", prostr); -// return 0; -// } +// printf("\"%s\"\n", prostr);\ + +// // 1-19 +// char d[MAXLINE]; +// char line[MAXLINE]; +// int len; +// while ((len = getlines(line,MAXLINE)) > 0) { +// reverse(line, d); +// printf("\nOriginal: %s\nReversed: %s\n", line, d); +// } + +// // 1-20 +// int len; +// char line[MAXLINE]; +// while ((len = detab(line,MAXLINE,8)) > 0) { +// printf("%s", line); +// } + + + return 0; +} // // PART OF 1-15 // float convert2cels(int fahr) { // return (5.0/9.0) * (fahr-32.0); // } -// // PART OF 1-16, 1-17, 1-18 +// // PART OF 1-16, 1-17, 1-18, 1-19 // int getlines(char s[],int lim) { // int c, i; // for (i=0; i < lim-1 && (c=getchar())!=EOF && c!='\n'; ++i) @@ -212,6 +234,38 @@ int main() { // s[i] = '\0'; // return i; // } + +// // PART OF 1-20 +// int detab(char s[],int lim, int col) +// /*s is the string we need to replace, lim is the character limit +// * and col is the size of a tab (8 characters usually so we use that)*/ +// { +// int c, i; /*c is the character integer representation and i is the column we are on*/ +// for (i=0; i < lim-1 && (c=getchar())!=EOF && c!='\n';) +// if (c == '\t') { +// int sp=col-i%col; /*Amount of spaces to replace the tab with*/ +// int st=i; /*Starting point*/ +// for (int co = 0; co<=sp; co++ && i++) { +// /*For each space we need to add, we increase the column count and add it +// *to the array at position (starting point + spaces added so far) +// * and we increase the spaces added so far*/ +// s[st+co] = ' '; +// } +// } else { +// s[i] = c; +// ++i; +// } +// if (c == '\n') +// /*If it is the end of the string, represented by a new line, +// * add that new line and increase it for the \0 addition*/ { +// s[i] = c; +// ++i; +// } +// /*Add the string end and return it to the previous context*/ +// s[i] = '\0'; +// return i; +// } + // /* copy: copy 'from' into 'to'; assume to is big enough */ // void copy(char to[], char from[]) { // int i; @@ -219,3 +273,12 @@ int main() { // while ((to[i] = from[i]) != '\0') // ++i; // } + +// // PART OF 1-19 +// void reverse(char s[MAXLINE], char d[strlen(s)+1]) { +// int len = strlen(s); +// for (int i=--len; i >= 0; --i) { +// d[len-i] = s[i]; +// d[len+1] = '\0'; +// } +// }