|
-
Feb 21st, 2002, 06:03 PM
#1
Thread Starter
Addicted Member
To protect time is to protect everything...
-
Feb 22nd, 2002, 09:07 AM
#2
transcendental analytic
flnm and str are wild pointers, point them to buffers or use those directly, ex:
char flnm[100];
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 22nd, 2002, 10:06 AM
#3
Thread Starter
Addicted Member
I know they are... I need an array of chars without knowing the exact number of indexes (an undifined array)... as far as i know there isnt any way to do that except with char *.... am i wrong?
To protect time is to protect everything...
-
Feb 22nd, 2002, 10:49 AM
#4
transcendental analytic
number of indexes is rather known as array size, arrays are defined, what you mean is dynamic arrays, and are allocated on the heap, I don't think you need a dynamic array in this case. you'll make it with a buffer of say 255 chars.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 22nd, 2002, 12:12 PM
#5
Thread Starter
Addicted Member
ok, i'll try ....... I just tried debugging my app when the fatal error appeared... and its coming up with and error on the str variable:
Error: CXX0030: Expression cannot be evaluated.... ???? The str's value is 0xcccccc "". Whats wrong... I know that it works because it works on my other computer.
To protect time is to protect everything...
-
Feb 23rd, 2002, 12:01 PM
#6
That's usually just a matter of luck. It may work, it may not, but even if it works, it is a very bad thing to do.
Since nobody has filenames longer than 256 characters, it's okay if flnm is a
char flnm[256];
I recommend using a dynamic array for str:
char *str;
// get length of file, don't know how with fstream
int iLength = LengthOfFile(flnm);
str = new char[iLength];
Don't forget to use delete or delete[] when done.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 24th, 2002, 06:15 PM
#7
Monday Morning Lunatic
What about NTFS? That doesn't have a 260-char limit
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Feb 25th, 2002, 10:42 AM
#8
I didn't talk about limits, I talk about practical use. You can extend the array to MAX_PATH to be sure on this side. (You must include windows.h for this constant.)
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 25th, 2002, 10:53 AM
#9
Fanatic Member
if you dont know how long its gonna be you can use
Code:
char *tmp = new char[]
if you're using VC++ and use strlen(), it'll be the length of the contents (i've tested it, it works, its in that other thread)
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Feb 25th, 2002, 07:59 PM
#10
Thread Starter
Addicted Member
do you have to use the delete or delete[] function after using the char *tmp = new char[];??
To protect time is to protect everything...
-
Feb 26th, 2002, 08:36 AM
#11
I still can't imagine that this gives you valid results...
They may work now, but it could cause problems later...
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 26th, 2002, 04:09 PM
#12
Thread Starter
Addicted Member
Ok, i am asking which is the best way to do it. I need a way to be able to read and write from some kind of string variable in a way that i can look at one character at a time (just like str[i] = ?). So whats the best kind of variable to use and how do you use it ( i know that the different types of string variables have different functions with them ) What about string (basic_string)?
To protect time is to protect everything...
-
Feb 26th, 2002, 04:23 PM
#13
Monday Morning Lunatic
Code:
string whatsit("Hello World");
for(int i = 0; i < whatsit.length(); ++i) {
cout << whatsit[i] << endl;
}
for(string::iterator k = whatsit.begin(); k != whatsit.end(); ++k) {
cout << *k << endl;
}
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|