Click here to Skip to main content
15,888,802 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Referencing lib file Pin
Mark Salsbery15-Nov-08 7:30
Mark Salsbery15-Nov-08 7:30 
GeneralRe: Referencing lib file Pin
Christian Flutcher16-Nov-08 6:56
Christian Flutcher16-Nov-08 6:56 
GeneralRe: Referencing lib file Pin
Mark Salsbery16-Nov-08 7:08
Mark Salsbery16-Nov-08 7:08 
GeneralRe: Referencing lib file Pin
Christian Flutcher16-Nov-08 7:12
Christian Flutcher16-Nov-08 7:12 
GeneralRe: Referencing lib file Pin
Mark Salsbery16-Nov-08 7:22
Mark Salsbery16-Nov-08 7:22 
GeneralRe: Referencing lib file Pin
Jijo.Raj16-Nov-08 7:34
Jijo.Raj16-Nov-08 7:34 
GeneralRe: Referencing lib file Pin
Christian Flutcher17-Nov-08 15:37
Christian Flutcher17-Nov-08 15:37 
QuestionProblems with malloc() and typedef struct Pin
Manfr3d15-Nov-08 3:11
Manfr3d15-Nov-08 3:11 
Hello guys,

I've created a struct and defined it as a new data type. However, when I want to declare a variable of this type there are several errors:
SMap: Illegal use of this type as expression
mySMap: undeclared identifier
<br />
#include <stdio.h><br />
#include <stdlib.h><br />
<br />
#ifndef NULL<br />
#define NULL 0<br />
#endif<br />
<br />
typedef struct<br />
{<br />
	int width;<br />
	int height;<br />
	char* data;<br />
} SMap;<br />
<br />
SMap* createMap(int width, int height);<br />
<br />
int main(int argc, char* argv[])<br />
{<br />
	int width;<br />
	int height;<br />
	printf("Enter width: ");<br />
	scanf("%i", &width);<br />
	printf("Enter height: ");<br />
	scanf("%i", &height);<br />
	<br />
	SMap* mySMap = (SMap*)malloc(sizeof(SMap));    // the errors refer to this line<br />
<br />
	return 0;<br />
}<br />
<br />
SMap* createMap(int width, int height)<br />
{<br />
	SMap* mymap = (SMap*) malloc(sizeof(SMap));<br />
	if (mymap == NULL)<br />
	{<br />
		return NULL;<br />
	}<br />
	mymap->width = width;<br />
	mymap->height = height;<br />
	mymap->data = (char*) malloc(width*height);<br />
	if (mymap->data = NULL)<br />
	{<br />
		free(mymap);<br />
		return NULL;<br />
	}<br />
	return mymap;<br />
}<br />
</stdlib.h></stdio.h>


I know that the use of malloc() isn't necessary in C++ but I want to compile the code as C-code.
Does anyone know why this doesn't work, maybe it's a basic thing I forgot about?

Thanks and best wishes.
AnswerRe: Problems with malloc() and typedef struct Pin
Iain Clarke, Warrior Programmer15-Nov-08 3:18
Iain Clarke, Warrior Programmer15-Nov-08 3:18 
GeneralRe: Problems with malloc() and typedef struct Pin
Manfr3d15-Nov-08 4:08
Manfr3d15-Nov-08 4:08 
AnswerRe: Problems with malloc() and typedef struct Pin
cmk15-Nov-08 9:21
cmk15-Nov-08 9:21 
GeneralRe: Problems with malloc() and typedef struct Pin
Manfr3d15-Nov-08 23:22
Manfr3d15-Nov-08 23:22 
GeneralRe: Problems with malloc() and typedef struct Pin
cmk16-Nov-08 8:47
cmk16-Nov-08 8:47 
Questionset focus to a control problem on win32 dialogs [modified] Pin
abdolahzadeh15-Nov-08 2:55
abdolahzadeh15-Nov-08 2:55 
AnswerRe: set focus to a control problem on win32 dialogs Pin
Code-o-mat15-Nov-08 3:36
Code-o-mat15-Nov-08 3:36 
GeneralRe: set focus to a control problem on win32 dialogs Pin
abdolahzadeh16-Nov-08 2:43
abdolahzadeh16-Nov-08 2:43 
AnswerRe: set focus to a control problem on win32 dialogs Pin
Mark Salsbery15-Nov-08 7:27
Mark Salsbery15-Nov-08 7:27 
GeneralRe: set focus to a control problem on win32 dialogs Pin
abdolahzadeh16-Nov-08 2:39
abdolahzadeh16-Nov-08 2:39 
QuestionRe: set focus to a control problem on win32 dialogs Pin
Mark Salsbery16-Nov-08 6:05
Mark Salsbery16-Nov-08 6:05 
AnswerRe: set focus to a control problem on win32 dialogs Pin
abdolahzadeh18-Nov-08 3:51
abdolahzadeh18-Nov-08 3:51 
GeneralRe: set focus to a control problem on win32 dialogs Pin
Phil Outram20-Sep-10 11:02
Phil Outram20-Sep-10 11:02 
QuestionSetRegistryKey problem, when uninstalling Pin
followait15-Nov-08 0:51
followait15-Nov-08 0:51 
AnswerRe: SetRegistryKey problem, when uninstalling Pin
22491715-Nov-08 17:38
22491715-Nov-08 17:38 
GeneralRe: SetRegistryKey problem, when uninstalling Pin
followait15-Nov-08 18:46
followait15-Nov-08 18:46 
Questiondate and time Pin
Russell'15-Nov-08 0:18
Russell'15-Nov-08 0:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.