Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // apple xcode
- // paulogp
- /* isnull: string nula */
- #include <stdio.h>
- #include <string.h>
- int isnull (char *the_input);
- int isnull (char *the_input)
- {
- //if (the_input[0] == '\0') // only the first is needed
- if (the_input == NULL) // when using fgets with strtok
- return 1; // null
- else
- return 0;
- }
- int main (int argc, const char * argv[])
- {
- char the_input[20]; // max 20 digits
- char *the_input_ptr;
- int the_result;
- printf ("palavra: ");
- fgets (the_input, sizeof(the_input), stdin);
- // token \n
- // NOTE: the_file_ptr points to the_file_name
- the_input_ptr = strtok (the_input, "\n");
- the_result = isnull (the_input_ptr);
- if (the_result == 1)
- printf ("nulo");
- else
- printf ("nao nulo");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement