0
char *arg;
arg = strstr(buff, 001);

This is giving me typecasting problem. How to store 001 in arg?

Donald Duck
  • 8,409
  • 22
  • 75
  • 99
saurabh
  • 17
  • 3

1 Answers1

2

This is giving me typecasting problem. How to store 001 in arg?

The second argument of the C function strstr must be of type const char *. You are instead passing an int. Use quotes.

arg = strstr(buff, "001");

VHS
  • 9,534
  • 3
  • 19
  • 43
  • 1
    The *parameter* is of type `const char*`. The *argument* can be `const char*` or `char*`. In this case it's of type `char*` (because C string literals, unlike C++ string literals, are not `const`). (`"001"` is actually of type `char[4]`, but it's implicitly converted at compile time to `char*`.) – Keith Thompson Feb 16 '17 at 19:57
  • Thank you @KeithThompson for additional detail. Appreciate your feedback. – VHS Feb 16 '17 at 19:58