now what happens is that if i place a char into buffer and add it to line[linesUsed].data with sprintf that exact same char is replicated through all 14 strings, so if i was to print all 14 strings out yhey are exactly the same where as im trying to change each string seperately can anyone see whats going on???
"" is a char const *, that is a pointer on the same address whatever the index in your array of line; so, when you append a string to a line, it is as if you appended to all lines. But what follows is worse : you are trying to modify a constant string which is only 1 byte long ("" <=> '\0') in a read only data section, so by appending this way you are scratching over other data being defined after your "" string. You are lucky that your app is not crashing. PSP has no read-only protection access on section since it has no MMU for that, so it doesn't raise an exception when you attempt to append a string to your constant string.
thanks for that i understand what you are saying, i have heard of this before just didnt strike me this time when i did it, is there another way to do what i want to do?? cause im having a bit of a mental block and cant see past my problem
reefbarman, you need basics of C, before starting programming. Because without it in future, you will get alot of problems with pointers and memory allocation.
i have alot of experience with programming just happens that not too much of it is with c, im currently doing my masters degree in Software Engineering and have had about 4 years coding experience with c++, java, php, python and shell, so as i said im alright and my preferred language is c++, so jumping back a notch to the c language just meant i didnt know some of the specifics and functions it uses, but if you would like to check out some of my coding work check out my current project http://reefbarman.110mb.com/pSPC%20Beta2.1.rar
Oh, man, I wasn't doubt that you are programmer. I was just thinking that you programmed on Pascal or Java, maybe C# before and now started on C/C++. And just warned you, because alot of C-programmers have problems, because don't know language in details.
But you writed, that you experienced with C++, it is surprising me. How you could make such foolish mistake in that case? What you was using when worked wtih strings? CString or std::string?
in c++ i always used std::string i had no other need to use c style strings and functions that required them, i have used them before but in no way anything similar to what i am doing with them now which is basically construction an osk and typing functions which would be alot easier in c++ so i am just having to learn as you said the basics again, thanks for your concern