0

Possible Duplicate:
How to convert integer to string in C?

I would like to calculate the length of the string and pass the value to a function as a string.

char* s="abcd";
int i = strlen(s);
char* lengthAsString = ????(i);
Community
  • 1
  • 1
dare2k
  • 417
  • 2
  • 7
  • 23

1 Answers1

4
char* s = "abcd";
int i = strlen(s);
char lengthAsString[50];
sprintf(lengthAsString, "%d", i);

// now you can use lengthAsString to pass it to a function
Kiril Kirov
  • 36,509
  • 22
  • 109
  • 183
aakash
  • 751
  • 5
  • 18