How to use strlen() in CodeBlocks?

I am working on a program where i have to made a word appear at centre and scroll left. I've written a program which will do the work but the problem is that my compiler (codeBlocks v16.01) is not accepting my code, i have tested the same code working on my friends computer.

The code is:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// ----------------------------------------------------
//               Scrolling a message.
// ----------------------------------------------------
#include <iostream>
#include <iomanip>
using namespace std;
#define DELAY 10000000L // Output delay
inline void cls() // Clear screen
{
cout << "\033[2J\n";
}
inline void locate(int z, int s) // Put cursor in row z
{ // and column s
cout << "\033[" << z << ';' << s << 'H';
}
char msg[] = "* * * B R E A K * * * ";
int main()
{
int i, start = 0, len = strlen(msg);
cls(); locate(24, 20); // Row 24, column 20
cout << "--- Press interrupt key to terminate (^C) ---";
while( true )
{
locate( 12, 25); // Row 12, column 25
i = start; // Output from index start
do
{
cout << msg[i++];
i = i % len; // if( i == len) i = 0;
}
while( i != start);
cout << endl; // Outputs buffer to screen
// Wait in short
for( int count = 0; count < DELAY; ++count)
;
++start; // For next output
start %= len; // start = start % len;
}
cls();
return 0;
}


Error compiler gives:

||=== Build: Debug in CodeBlocks (compiler: GNU GCC Compiler) ===|
C:\Users\...\Documents\CodeBlocks\main.cpp||In function 'int main()':|
C:\Users\...\Documents\CodeBlocks\main.cpp|25|error: 'strlen' was not declared in this scope|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 28 second(s)) ===|


Any help will be appreciated. Thanks in advance!
closed account (48T7M4Gy)
http://www.cplusplus.com/reference/cstring/strlen/

Make sure you have the right #includes
Originally Posted By kemort
http://www.cplusplus.com/reference/cstring/strlen/

Make sure you have the right #includes


I forgot to include string header....

Sorry for such foolish question.
closed account (48T7M4Gy)
No need to apologize, just good that problem is fixed.
Topic archived. No new replies allowed.