Skip to content

Instantly share code, notes, and snippets.

@ericfode
Forked from anonymous/sentences.c
Created May 7, 2012 00:46
Show Gist options
  • Save ericfode/2625195 to your computer and use it in GitHub Desktop.
Save ericfode/2625195 to your computer and use it in GitHub Desktop.
c program
#include <stdio.h>
#include <string.h>
//Declaring variables..
int numOfSentences;
int numOfWords;
char word[1]; //temp variable to read in stuff from the file and check it.
char articles[10];
char *artptr = articles;
/*char nouns[];
char verbs[];
char prepositions[];
char sentences[];
*/
int main()
{
scanf("%d", &numOfSentences);//read in the numOfSentences
//this is a test
scanf("%s", word);
scanf("%d", &numOfWords);
for(int x=0; x < numOfWords; x++, artptr += articles[x])
{
scanf("%s", artptr);//articles[x]);
articles[x] = artptr;
printf("%s\n",artptr);
}
/* while(scanf("%s",word) != EOF)
{
if(word == "Articles")
{
scanf("%s", articles);
}
else if(word == "Nouns")
{
scanf("%s", nouns);
}
else if(word == "Verbs")
{
scanf("%s", verbs);
}
else if(word == "Prepositions")
{
scanf("%s", prepositions);
}
}//end while loop
*/
//print out the contents of the arrays to see if it went in correctly.
// printf(articles,"\n", nouns, "\n" , verbs, "\n", prepositions);
printf("\n%d\n\n%s\n\n%d\n\n\n", numOfSentences, word, numOfWords);//, articles);
for(int i =0; i < numOfWords -1; i++)
{
printf("%s ", articles[i]);
}
return(0);
}//end main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment