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?

  1. MVS 2012 Compiler
  • Replace #include <stdafx.h> . - VladD
  • What compiler? - BogolyubskiyAlexey
  • @BogolyubskiyAlexey: based on the logs, I would venture to suggest that Visual Studio 2012> c: \ users \ alexey \ documents \ visual studio 2012 [...] - VladD

1 answer 1

First of all, note that C ++! = C

secondly, you mix two different languages ​​from that and a problem, if you want to use C libraries in a modern C ++ compiler, then remove .h and specify the prefix "with" (instead of "string.h" write "string" and the same with stdio)

in the third, how to connect old libraries, you will receive errors according to your code, which will need to be corrected