Started working on exercise 7

This commit is contained in:
Jack-Benny Persson 2015-10-19 05:53:58 +02:00
parent 0dbfe8f78a
commit b86ee577dc
2 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,30 @@
#include <stdio.h>
/* My solution to exercise 7 chapter 2 from "Vägen till C".
* Not done yet...
*/
int main()
{
char c, all[100];
int i = 0;
int j= 0;
while ((c = getchar()) != EOF)
{
all[i] = c;
i++;
}
all[i] = '\0';
while (all[j] != EOF)
{
if (all[i] == ' ' || all[i] == '\n')
{
putchar('\n');
}
putchar(all[j]);
j++;
}
putchar('\n');
}

View File

@ -0,0 +1,12 @@
#include <stdio.h>
/* Another solution to to exercise 7, chapter 2, "Vägen till C".
* Not done yet...
*/
int main()
{
char c[100];
scanf("%100[0-9a-zA-Z ]", c);
printf("%s\n", c);
}