YAY! I made my first encryption algorithm :D

Something interesting occured a few moments ago from the time I typed this message up.

I was doing small excercises about pointers and when I was going to the next excercise I have seen an example. I didn't read anything else but the example and best of all I read the code and what it had done. I am starting to understand pointer relationships. :D

I have been spending hours working on pointer excercises and it's really getting into my head. :)
I wander if I should take a break soon?

I'm so excited that I had to post it. :)

I also understand what my problems are with my encryption algorithm.
I'm going to start from scratch so I don't have to read my confusing code. :LOL:

I should use an array and then assign the entire array into that pointer and modify what I must that way.

*pt = *pt * 2; will multiply everything stored in that pointer by 2. Not very good encryption but I have something far better planned.

I believe the trick to making my encryption alg. is to get comfortable with my pointers.

Thanks for the help guys. I guess practice is the only way for me to understand. I wander if that is a bad thing?
I would much rather understand pointers 100% by just reading a line of text. :LOL:
 
You will not see the null character if you view the data as a string, the only way to see it is to look at the array in memory, the null character is just zero.


Re your pointer thing.

*pt = *pt * 2; will multiply everything stored in that pointer by 2. Not very good encryption but I have something far better planned.

NO!
That will just multiply the first element of the array.
A pointer is nothing more that what it says, it points to one value of the type of the pointer. To change all the elements of an array you have to modify the pointer to point to each element in turn, and then modify each one. Pointers do not know anything about sizes of arrays etc.

CC
 
NO!
That will just multiply the first element of the array.
A pointer is nothing more that what it says, it points to one value of the type of the pointer. To change all the elements of an array you have to modify the pointer to point to each element in turn, and then modify each one. Pointers do not know anything about sizes of arrays etc.

Nuts, isn't there any shortcut in existence to allow a multiplication of everything in an array?
 
Use Fortran.
Or alternatively define your own (templated) vector class which maps the relevant operators.
Oh wait, isn't there already something like this in the STL? *shrugs*.
 
I read that there is something called a smart pointer. I wander what the difference between both types of pointers are?

I heard of Fortran, I prefer to do all y work in C++. :)

Thanks
 
Back
Top