diff --git a/.kdev4/LearningC.kdev4 b/.kdev4/LearningC.kdev4 index 2ffd5cd..d3e17e6 100644 --- a/.kdev4/LearningC.kdev4 +++ b/.kdev4/LearningC.kdev4 @@ -1,2 +1,19 @@ +[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 + [Project] VersionControlSupport=kdevgit diff --git a/main b/main new file mode 100755 index 0000000..48241d1 Binary files /dev/null and b/main differ diff --git a/main.c b/main.c index cdcf638..e269483 100644 --- a/main.c +++ b/main.c @@ -8,6 +8,11 @@ // // PART OF 1-15 // float convert2cels(int fahr); +// // PART OF 1-16, 1-17 +// #define MAXLINE 1000 +// int getlines(char line[], int maxline); +// void copy(char to[], char from[]); + int main() { // // 1-1 // printf("Hello, World!\n"); @@ -148,10 +153,69 @@ int main() { // celsius = celsius + STEP; // } - return 0; -} +// // 1-16 +// int len; +// /* current line length */ +// int max; +// /* maximum length seen so far */ +// char line[MAXLINE]; +// /* current input line */ +// char longest[MAXLINE]; +// /* longest line saved here */ +// max = 0; +// while ((len = getlines(line, MAXLINE)) > 0) +// if (len > max) { +// max = len; +// copy(longest, line); +// } +// if (max > 0) /* there was a line */ +// printf("Character count: %d\n%s", max, longest); + +// // 1-17 +// char line[MAXLINE]; +// int len; +// while ((len = getlines(line,MAXLINE)) > 0) { +// if (len > 80) +// printf("%s", line); +// } + +// // 1-18 +// char line[MAXLINE], prostr[MAXLINE]; +// int len; +// int skip = 0; +// while ((len = getlines(line, MAXLINE)) > 0) { +// for (int i=len; !(i < 0); --i) { +// if (skip != 0 || !(line[i] == ' ' || line[i] == '\n' || line[i] == '\t' || line[i] == '\0')) { +// prostr[i] = line[i]; +// skip = 1; +// } +// } +// } +// printf("\"%s\"\n", prostr); +// 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 +// int getlines(char s[],int lim) { +// int c, i; +// for (i=0; i < lim-1 && (c=getchar())!=EOF && c!='\n'; ++i) +// s[i] = c; +// if (c == '\n') { +// s[i] = c; +// ++i; +// } +// s[i] = '\0'; +// return i; +// } +// /* copy: copy 'from' into 'to'; assume to is big enough */ +// void copy(char to[], char from[]) { +// int i; +// i = 0; +// while ((to[i] = from[i]) != '\0') +// ++i; +// }