home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c:19402 comp.lang.c++:18826
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!uicvm.uic.edu!u10139
- Organization: University of Illinois at Chicago
- Date: Thu, 7 Jan 1993 23:05:24 CST
- From: T J Furstenau <U10139@uicvm.uic.edu>
- Message-ID: <93007.230524U10139@uicvm.uic.edu>
- Newsgroups: comp.lang.c,comp.lang.c++
- Subject: Dynamic Mem Help
- Lines: 43
-
- I hope someone on the net can help me with this problem. I'm trying
- to teach myself C and while working on dynamic memory allocation, I've
- run into a problem with the 'calloc' function. When I try to run the
- following code, taken straight from the 'help' example with the
- compiler,
-
- #include <stdio.h>
- #include <alloc.h>
- #include <string.h>
-
- int main(void)
- {
- char *str = NULL;
-
- /* allocate memory for string */
- str = calloc(10, sizeof(char));
-
- /* copy "Hello" into string */
- strcpy(str, "Hello");
-
- /* display string */
- printf("String is %s\n", str);
-
- /* free memory */
- free(str);
-
- return 0;
- }
-
- I get the following error message:
-
- Error D:\BC\BIN\WORK\NONAME00.CPP 10: Cannot assign 'void near*' to
- 'char near*' in function main().
-
- Any ideas in what I or my system are doing wrong? Are my compiler options
- set wrong? Any answers, here or mailed, would be greatly appreciated.
-
-
- ***************************************************************************
- * T J Furstenau | Your clever saying | Looking for a position *
- * Grad May 92 BS-Math/CS | could fill this | as a programmer. Anyone *
- * U10139@UICVM.UIC.EDU | space | hiring? *
- ***************************************************************************
-