Needing a little advice: I have a program here and I can't figure out how to use a pointer to process a string of characters. I need to add a function assert() inside read_in() to test if MAXLINE characters are exceeded when a sting is put it, but I'm not sure how to return what I get to read_in or if I need to really, and how to access the elements of the string entered. Here is the code:
Code:include <stdio.h> #define MAXLINE 100 void read_in(char*); int main(void) { char line(MAXLINE), printf("\nWhat is your favorite line? "); read_in(line); return 0; } void read_in(char s[]) { int c, i = 0; while ((c = gethcar()) != EOF && c != '\n') s[i++] = c; s[i] = '\0'; {
I've tried some things and can't get them to work.
Any help would be greatly appreciated.
Thanks.