Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


again a QUESTÝON about pointers

This topic is 5381 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

#include <iostream>
using namespace std;


unsigned int mystrlen(char*);
char* mystrcpy(char* , char* const); 


int main()
	char yazi2;
	char* yazim="bu alemin krali geliyorrrr";
	return 0;


unsigned int mystrlen(char* anystr)
	unsigned int cntr1=0;
	for(  ; *(anystr+cntr1)!=''\0''; ++cntr1)
	return cntr1;
char* mystrcpy(char* destination,char* const  source)
	unsigned int cntrdes=mystrlen(destination);
	unsigned int cntrsour=mystrlen(source);
	switch (cntrdes>=cntrsour)
	case true:
			int cntr1=0;
				*(cntrdes+cntr1)=*(source+cntr1);  // this is causing error

		*(destination+cntr1)=''\0'';   // this too..	             

	case false:
			int cntr2=0;
			for( ; cntr2<=cntrdes;++ cntr2)
				*(destination+cntr2)=*(source+cntr2);  // this is also causing error

			*(destination+cntr)=''\0'';   // this too..

	return destination;

/*  all i want to do is   with this code is to assign value of source char to  destination char
 as that
	   destination[cntr1]=source[cntr1];     // but i want to do that wiht pointers

       what is wrong at that code and how can i do that
	   *(cntrdes+cntr1)=*(source+cntr1);       ???

  second question is
  how can i get the content of a pointer to char*(assume as a array..)



the archer who shoots his arrow beyond his target is no more successful than the one who''s arrow didn''t even reach the target.

Share this post

Link to post
Share on other sites
I would recomend the following changes:


"char *yazi2" instead "char yazi2"

You receive an error in true statement in line *(cntrdes + cntr1) =... because instead of cntrdes should be destination . Cntrdes is an int and is a right-value.

Last error: cntr should be replaced with cntr2.

Good luck!

Codman - "The source for all things"
"We design for eternity"

Mail: Codman_Wu@personal.ro

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!