You must enter a line, display it word by word on the screen, but the words are in reverse order. I wrote a program, but not roby .____.
#include <stdio.h> #include <string.h> void print_reversed_words(char * str, const char * delim) { if ( str = strtok(str, delim) ) { print_reversed_words(NULL, delim); printf("%s ", str); } } typedef char string_t[256]; #define get_string(s) ( scanf("%255[^\n]%*c", (s)) == 1 ) #define DELIM " \t\n" int main(void) { string_t str; while ( printf("\nString: ") && get_string(str) && printf("Reversed: ") ) print_reversed_words(str, DELIM); return 0; }
Complains about
1> c: \ users \ alexey \ documents \ visual studio 2012 \ projects \ consoleapplication1 \ consoleapplication1 \ consoleapplication1.cpp (2): warning C4627: #include <string.h>: omitted when searching for using a precompiled header
1> c: \ users \ alexey \ documents \ visual studio 2012 \ projects \ consoleapplication1 \ consoleapplication1 \ consoleapplication1.cpp (6): error C3861: strtok: identifier not found
The head does not cook all day, what's the problem?
- MVS 2012 Compiler
#include <stdafx.h>
. - VladD