E
Eric A. Johnson
Hi, I'm going through a book I got from the library. Admittedly, the book
is old -- it hails from 1994, and much has changed since then. However, I
would like to learn as much as possible from the book, as it covers some
very interesting topics.
I have an error that is a bit confusing to me, and the help I get from
pressing F1 on it is to general to be of much assistance. The following is
the code snippet that is giving me the error, followed by the error:
#include <stdio.h>
#include <stdlib.h>
#define NAME_SIZE 35
void main(void)
{
long student_ctr = 0;
long ctr;
char *student_name = NULL;
while( (student_name =
realloc( student_name,
(NAME_SIZE * (student_ctr+1)))) != NULL )
{
/* ...Buncha stuff here... yada yada yada
}
--------------------Configuration: SamListing01_05 - Win32
Debug--------------------
Compiling...
SamListing01_05.cpp
C:\Program Files\Microsoft Visual
Studio\MyProjects\SamListing01_05\SamListing01_05.cpp(19) : error C2440: '='
: cannot convert from 'void *' to 'char *'
Conversion from 'void*' to pointer to non-'void' requires an
explicit cast
C:\Program Files\Microsoft Visual
Studio\MyProjects\SamListing01_05\SamListing01_05.cpp(19) : fatal error
C1903: unable to recover from previous error(s); stopping compilation
Error executing cl.exe.
SamListing01_05.exe - 2 error(s), 0 warning(s)
....I am primarily interested, of course, in how to modify this program so
that I can get it to compile and run without errors. If you need the rest
of the code, I will gladly supply it... but it pointed to the last line of
the while statement for the location of the error. I will be grateful for
any help... even tips on how this may not, for example, conform with ANSI C,
or differences between the C of '94 and of today. Thank you!
-- Eric A. Johnson
is old -- it hails from 1994, and much has changed since then. However, I
would like to learn as much as possible from the book, as it covers some
very interesting topics.
I have an error that is a bit confusing to me, and the help I get from
pressing F1 on it is to general to be of much assistance. The following is
the code snippet that is giving me the error, followed by the error:
#include <stdio.h>
#include <stdlib.h>
#define NAME_SIZE 35
void main(void)
{
long student_ctr = 0;
long ctr;
char *student_name = NULL;
while( (student_name =
realloc( student_name,
(NAME_SIZE * (student_ctr+1)))) != NULL )
{
/* ...Buncha stuff here... yada yada yada
}
--------------------Configuration: SamListing01_05 - Win32
Debug--------------------
Compiling...
SamListing01_05.cpp
C:\Program Files\Microsoft Visual
Studio\MyProjects\SamListing01_05\SamListing01_05.cpp(19) : error C2440: '='
: cannot convert from 'void *' to 'char *'
Conversion from 'void*' to pointer to non-'void' requires an
explicit cast
C:\Program Files\Microsoft Visual
Studio\MyProjects\SamListing01_05\SamListing01_05.cpp(19) : fatal error
C1903: unable to recover from previous error(s); stopping compilation
Error executing cl.exe.
SamListing01_05.exe - 2 error(s), 0 warning(s)
....I am primarily interested, of course, in how to modify this program so
that I can get it to compile and run without errors. If you need the rest
of the code, I will gladly supply it... but it pointed to the last line of
the while statement for the location of the error. I will be grateful for
any help... even tips on how this may not, for example, conform with ANSI C,
or differences between the C of '94 and of today. Thank you!
-- Eric A. Johnson