Compiler error: memset was not declared in this scope

michael picture michael · Mar 24, 2010 · Viewed 160.7k times · Source

I am trying to compile my C program in Ubuntu 9.10 (gcc 4.4.1).

I am getting this error:

Rect.cpp:344: error: ‘memset’ was not declared in this scope

But the problem is I have already included in my cpp file:

#include <stdio.h>
#include <stdlib.h>

And the same program compiles fine under Ubuntu 8.04 (gcc 4.2.4).

Please tell me what am I missing.

Answer

sth picture sth · Mar 24, 2010

You should include <string.h> (or its C++ equivalent, <cstring>).