View Single Post
Old Jun 5th, 2006, 6:52 PM   #21
Harakim
Hobbyist Programmer
 
Join Date: May 2006
Location: West Jordan, Utah, United States
Posts: 176
Rep Power: 3 Harakim is on a distinguished road
Although this isn't technically true "char *name" and "char name[xx]" are basically the same.

When you are passing an array in C, you can pass it as a pointer and dereference it with brackets.

int foo( char *bar )
{
	bar[1] = 100;
}


int foo2()
{
	char bar2[20];
	
	foo( bar2 );	

	//bar2[1] now equals 100
}


I have heard that they are not the same at all, so hopefully someone will be enraged by my saying they are and come and explain it. As for passing arrays though, I'm pretty sure that should work.

int foo( char **bar )
{
	bar[1][2] = 100;
}


int foo2()
{
	char bar2[20][10];
	
	foo( bar2 );	

	//bar2[1][2] now equals 100
}

EDIT: fixed error in code
Harakim is offline   Reply With Quote