Search Results

Showing results 1 to 40 of 125
Search took 0.01 seconds.
Search: Posts Made By: monkey_king ; Forum: C++ and child forums
Forum: C++ Jul 14th, 2009
Replies: 4
Views: 330
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
post your compile errors
Forum: C++ Jun 18th, 2009
Replies: 7
Views: 1,179
Posted By monkey_king
Could you try doing a
'ldd libPixyCANopen.so'
Forum: C++ Jun 17th, 2009
Replies: 7
Views: 490
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
What have you included,
this doesn't look like std c++
Forum: C++ May 21st, 2009
Replies: 18
Views: 574
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
So whats the problem?
Forum: C++ May 21st, 2009
Replies: 10
Views: 556
Posted By monkey_king
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
Posted By monkey_king
I have no ****ing idea what the question is
Forum: C++ May 20th, 2009
Replies: 18
Views: 574
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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
Solved: Sorting vectors
Views: 697
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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
Posted By monkey_king
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....
Showing results 1 to 40 of 125

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC