> I have written a c program with 256 nested for loop.
This is fundamentally wrong, unless you were doing it for purposes of testing the implementation of a compiler. Consider using a different algorithm (an elegant option would be to write it recursively).
> I have also heard that we can run a C++ program with 256 nested for loop.
The standard does not guarantee it.
Nesting levels of compound statements, iteration control structures, and selection control structures [256].
The bracketed number following each quantity is recommended as the minimum for that quantity. However, these quantities are only guidelines and do not determine compliance. |
> I have heard that it is not possible to run this program in C.
You may be able to run such a program in C. Unlike C++, C does impose minimum requirements on implementations; IIRC, C99 requires that an implementation shall be able to translate a program with
127 nesting levels of blocks. This is the lower limit; an implementation may allow deeper levels of nesting, and IIRC the C99 standard suggests that if possible, the implementation should not impose fixed limits.
> After adding suitable c header files, Can I able to use string functions: strlen, strcat;
> file functions fopen, fclose, fgets; memory functions: free and malloc in same way as we use in C.
Yes, C compatibility headers are available. Almost in the same way. For example:
1 2
|
int* p = malloc( 100 * sizof(int) ) ;
double* q = p ;
|
is valid C, but not valid C++.
Ideally include the standard C++ headers
<cstring>,
<cstdio> etc. and then use
std::strlen,
std::fopen etc.
For details, see:
http://en.cppreference.com/w/cpp/header