![]() |
|
#1
|
|||
|
|||
Pointers and C ++ (use)i am taking data structure I , but it seems that i did not get the real use of pointers with classes, so i was thinking to create a programm that reads a text file pass it to a string , then a have a pointer char to go through each characters fron that file and convert it (from ascii to the binary code equivalent and write it into another output file) [ My whole goal is to create a decypter for text files at the end i know i may not finish this idea or i may in the wrong direction but at least i want to understnd pointers from my idea so i am doing in two part: the first part will just do what is described above if it works fine than i will move to changing the dycryption method and then without know the decryption formula i will try to find the algorithm ] so i any one can help me it will be greatly appreciated.
|
|||
|
#2
|
|||
|
|||
Re: Pointers and C ++ (use)Quote:
If you read in the entire file into memory, than the file size is limited by the amount of remaining available memory in the process space. I would suggest just reading in a single line at a time & encrypt/decrypt just that. We see an abundance of people who are completely befuddled by implementing all (& then some...) features/functionality at once. Make life simpler for yourself by incrementally building your application:
|
|
#3
|
|||
|
|||
Re: Pointers and C ++ (use)why this code is not working properly ?
CPP / C++ / C Code:
CPP / C++ / C Code:
unless we have to have a char variable that has a value first maybe that will be the reason so i tried this way still not working and that is what i don't get about pointers like i can not tell what this statements means reall: CPP / C++ / C Code:
i have a text file that i created with a notepad.txt. I added couple of lines without using any Return button(keyboard) i made sure there is no space after the last char int his text. now how to read that char by char and put it into an array(i think my problem is not beeing able to get the right function from the class<fstream> So my final goal is to read from an unknowing size txt file that print those character into another file. |
|
#4
|
||||
|
||||
Re: Pointers and C ++ (use)Quote:
__________________
During the election they said Obama could only be elected when pigs fly. Well, we currently have an epidemic of Swine Flu. Coincidence? |
|
#5
|
|||
|
|||
Re: Pointers and C ++ (use)ok so how can i assign a char pointer to a string base position;
example : CPP / C++ / C Code:
same technique going through char by char and write the output to another txt file. |
|
#6
|
|||||||
|
|||||||
Re: Pointers and C ++ (use)Please post complete examples which compile. Posting snippets only makes sense if the full example has previously been posted.
Quote:
Quote:
http://www.cplusplus.com/reference/s...ing/c_str.html Quote:
|
|
#7
|
|||
|
|||
Re: Pointers and C ++ (use)Thanks as i get what was u trying to say by void g(int*);i am ok with passing by value and refrence and to point a pointer to var just we use this statement : p=&i; now p points to i and changing *p will alter i automatically;
here is two full code with a text file attched to them i commented what i did not get, i hope this will clear everything thanks forward; CPP / C++ / C Code:
CPP / C++ / C Code:
now how if i have a text file with a big size will the same technique work ? i forget to say my text file is: "thanks ocicat for the help" i named it sample.txt ; |
|
#8
|
|||
|
|||
Re: Pointers and C ++ (use)hi ocicat i see u online can u check my last response if u have a chance thanks
|
|
#9
|
|||
|
|||
Re: Pointers and C ++ (use)Although I suspect you are simply doing a cut-&-paste potentially from Microsoft's Developer Studio or some other environment which may massage tabs & spaces into coherent indentation, the code posted is nearly incomprehensible.
Quote:
CPP / C++ / C Code:
CPP / C++ / C Code:
Quote:
|
|
#10
|
|||
|
|||
Re: Pointers and C ++ (use)Hi, In the code posted earlier there is a mistping line i put temp instead of ascii so i am reposting it again
Ocicat you said that you suspecting that i am copying and pasting ok i send the source code that i wrote from scratch, if we all agree that encryption is something that means reading data and changing the dispay of actual datat to a different form that dispaly a different output so that was my project. as i wanted to try it with pointers to char i made a sample test file where i wrote a string in it saved it with notepad i iopened it in the main function then i created i declared a variable int ascii with a while loop i am reading through my sample text file the in.get(*ch) takes the first char from the text if this char is blank the ascii code 32 is assigned else the integer ascii to the (*ch) which will put the ascii code of the character in ascii i am dispaying throught the screen and writng to another text file called output.txt i am incremeting the pointer ch )char type) to the next char uing ch++; closing both files So i did another version instead of using *ch i used just a variable characheter and it did work and u can try to compile it and see all u have to if u are using VC++ express edition is to create a dummy text file type whaterver in it and save it then run the program. */ CPP / C++ / C Code:
|
Recent GIDBlog
Problems with the Navy (Chiefs) by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Sort an array of structures | sassy99 | C Programming Language | 10 | 15-Feb-2007 08:46 |
| [Tutorial] Function Pointers | aaroncohn | C++ Forum | 4 | 17-Feb-2006 12:33 |
| [Tutorial] Pointers in C (Part II) | Stack Overflow | C Programming Language | 0 | 27-Apr-2005 18:36 |
| [Tutorial] Pointers in C (Part I) | Stack Overflow | C Programming Language | 1 | 08-Apr-2005 19:35 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The