Forum: C++ Jul 14th, 2009 |
| Replies: 4 Views: 330 If the size is determined at runtime you need a full fleged dynamic memory version. Something like
#include <iostream>
int **allocs(int x,int y){
int **ret = new int*[x];
for(int... |
Forum: C++ Jul 14th, 2009 |
| Replies: 3 Views: 182 Just try to do the program,
when its done, it should be clear what should be pointers. |
Forum: C++ Jul 8th, 2009 |
| Replies: 14 Views: 492 Hi omir
People are normally quite friendly inhere,
but you should ask a specific question.
good luck |
Forum: C++ Jul 8th, 2009 |
| Replies: 3 Views: 616 Hi I got a code that in pseudo dos something like
ifstream os;
while(os.oef()){
os.getline(buffer,length);
}
If some condition is met, |
Forum: C++ Jul 8th, 2009 |
| Replies: 4 Views: 266 What would your rule be for definingen when a token/line is invalid?
I would check the the number of tokens in each class is first 2, then 8
Or do you want a more elaborate check? |
Forum: C++ Jun 18th, 2009 |
| Replies: 15 Views: 631 |
Forum: C++ Jun 18th, 2009 |
| Replies: 7 Views: 1,179 Could you try doing a
'ldd libPixyCANopen.so' |
Forum: C++ Jun 17th, 2009 |
| Replies: 7 Views: 490 I normally wont go into small errors in other peoples posting,
but it should be noted that code::blocks is an ide.
The compiler is most likely(depending on the setup) the mingw compiler. The mingw... |
Forum: C++ Jun 17th, 2009 |
| Replies: 7 Views: 1,179 It's shouldn't be necessary to use extern,
generally you have access to all the public variables and function in the symboltable, but only the externed are required to have the same signature, from... |
Forum: C++ Jun 17th, 2009 |
| Replies: 5 Views: 659 I think it depends on what you are doing with the file.
I've found that the FILE, strtok is by far the fastest way of reading in data.
I've been using flat files, (same number of columns in all... |
Forum: C++ Jun 16th, 2009 |
| Replies: 8 Views: 524 Yes,
you've added 'delete []', and have to dereference the double pointers.
Thanks for your help again ancient dragon. |
Forum: C++ Jun 16th, 2009 |
| Replies: 8 Views: 524 Thanks ancient dragon,
the trick was passing a pointer pointer then.
@arkm
The programming problem is simple.
check if a char* contains a trailing slash,
otherwise update the char*, so that... |
Forum: C++ Jun 16th, 2009 |
| Replies: 8 Views: 524 Hmm thanks for the char[] approach.
But I cant nail down my problem with the updated cstring.
The following code
#include<iostream>
#include<cstring>
void fix_name(char *name){ |
Forum: C++ Jun 15th, 2009 |
| Replies: 8 Views: 524 Hi
I'm having a very basic newbie problem,
The compiler forces me to do a strdup (because of cons correctness),
can I void the extra line in my code, and then I cant seem to update my array
after... |
Forum: C++ May 31st, 2009 |
| Replies: 13 Views: 1,106 Cheers arkM,
I will for sure look into this.
The avl is not part of the stl right?
So I have to make this one up.
As it is, the lookup map, takes aprox 3-4 gig memory,
I have 8 gig, but... |
Forum: C++ May 31st, 2009 |
| Replies: 13 Views: 1,106 I'm parsing 900 gig of textfiles
Using std::string as opposed to char* directly from getline,
takes around 40-60% longer. |
Forum: C++ May 31st, 2009 |
| Replies: 13 Views: 1,106 Thanks for your response.
Is the const_cast necessary because i definded my map as a
typedef std::map <const char*,int> aMap;
instead of
typedef std::map <char*,int> aMap; |
Forum: C++ May 31st, 2009 |
| Replies: 13 Views: 1,106 Cheers arkM,
I have no idea what happened here...
But the const_cast is not really necessary, is it? |
Forum: C++ May 30th, 2009 |
| Replies: 13 Views: 1,106 For anyone that cares,
this seems to do the trick.
But it is important that the item decleration is used directly at the assignmen operator
my_map::value_type item = *it;
data.erase(it);... |
Forum: C++ May 29th, 2009 |
| Replies: 13 Views: 1,106 Yes I know,
this is what I write in my original post.
How do I free the memor, that I've allocated. |
Forum: C++ May 29th, 2009 |
| Replies: 8 Views: 334 It's in the nature of finite precision.
Theres not much you can do about it.
there a basicly two kinds of datatypes.
1. integral
2. float
integral being, int, char, byte etc
floats being,... |
Forum: C++ May 29th, 2009 |
| Replies: 13 Views: 1,106 Hi,
can anyone tell me why i can't clean up the memory,
and maybe a small solution.
I'm allocing memory with strdup for each key,
but I cant figure out how to erase the key with free.
Before... |
Forum: C++ May 21st, 2009 |
| Replies: 15 Views: 700 What have you included,
this doesn't look like std c++ |
Forum: C++ May 21st, 2009 |
| Replies: 18 Views: 574 void initialize_file(Horses temp_array[]) {
string line;
ifstream HorsesFile ("HorsesFile.txt");
if (HorsesFile.is_open()) {
while (! HorsesFile.eof() ) {
getline (HorsesFile,line);
... |
Forum: C++ May 21st, 2009 |
| Replies: 14 Views: 576 Write an example on datainput, and dataoutput,
like
int inPut=1234;
char *output= \\how do I convert 1234 to char* |
Forum: C++ May 21st, 2009 |
| Replies: 6 Views: 318 I think this is an excellent example of why humans shouldnt use automated translation programs. Like babelfish and translate.google.
I understand he wants to write a calculator that uses polish... |
Forum: C++ May 21st, 2009 |
| Replies: 15 Views: 700 |
Forum: C++ May 21st, 2009 |
| Replies: 10 Views: 556 If you want to read in a matrix you need some considerations.
First of all you need some cind of datastructure to have the data in some datatype.
A int** would be very suitable.
But you need... |
Forum: C++ May 20th, 2009 |
| Replies: 4 Views: 254 I have no ****ing idea what the question is |
Forum: C++ May 20th, 2009 |
| Replies: 18 Views: 574 I don't understand your problem.
Doesn't the 500 line code work?
Is it a design question?
In a general context in c++,
you never have to write a method that does the sorting.
It's a good... |
Forum: C++ May 20th, 2009 |
| Replies: 5 Views: 230 I'm not an expert,
but you should be able to do it.
I think its called an aggregate class
http://en.wikipedia.org/wiki/C%2B%2B_structure#Aggregate_classes |
Forum: C++ May 19th, 2009 |
| Replies: 5 Views: 554 Hi,
Thanks for you reply,
apparently I don't get notified when people reply anymore.
So sorry for the delayed response.
I was using std::string,
But it is ridicously slow compared to char*.
... |
Forum: C++ May 12th, 2009 |
| Replies: 13 Views: 697 What is the ordering?
If you want to sort by the most frequent elements first, then you can use the link given to you.
If you are sorting by some other rule,
you should say what rule that is. |
Forum: C++ May 12th, 2009 |
| Replies: 5 Views: 554 I solved it,
strdup uses malloc,
so whenever you use a these cstring functions,
you should use free and not delete. |
Forum: C++ May 12th, 2009 |
| Replies: 5 Views: 554 Hi thanks for your reply,
but I don't know the syntax for clearing something that has been allocted like
char ***tokens;
(*tokens) = new char*[len];
for(int i=0 ; i<len ; i++)
(*tokens)[i]... |
Forum: C++ May 11th, 2009 |
| Replies: 5 Views: 554 I'm trying to get myself acquainted with memory allocation and deallocation while writing a program that will actually be usefull for me.
The program is a simple datareader, that tries to read a... |
Forum: C++ Mar 31st, 2009 |
| Replies: 2 Views: 566 when you use new the argument it takes is a size_t
normally everyone is simply using an int since this is enough for most purposes.
the type of size_t is implementation specific, on my computer its... |
Forum: C++ Mar 31st, 2009 |
| Replies: 15 Views: 993 just out of curiosity,
what does your init method do?
-----------------------------------------
I would do some thinking about the problem before i started coding.
What base do you need to... |
Forum: C++ Mar 31st, 2009 |
| Replies: 15 Views: 993 Do you just need to use huge integers,
then check the links given by tux4life.
Or is this some kind of school assignment? |
Forum: C++ Mar 30th, 2009 |
| Replies: 15 Views: 993 What exactly do you want, your question is to general.
If you want to represent a arbitrary integer,
you could use a int array, and only assume you will be using vals from 0-9 on each entry.... |