Salem 5,265 Posting Sage

What's wrong is you can't read.

> while((element=(getchar())!=EOF))
Is exactly the same as your original post, with more parentheses.
Go read my reply again, and study where I placed them.
No wait, that won't work this time, any more than it did last time.

Here, the critical ( ) emphasised while([B]([/B]element=getchar()[B])[/B]!=EOF) Plus you ignored the whole clearerr thing I mentioned.

Here, paste this as your loop.

while(element=getchar()!=EOF)
    {
[B]        printf( "Interesting, element is decimal %d\n", element );
[/B]        element=element-97;
[B]        if ( element < 0 ) printf( "OMG, WTF, it's now %d\n", element );
[/B]        l=(letters)element;
        if(l>=a&&l<=z)
        set[l]=true;
    }

Putting temporary printf statements all over the place is the first step to debugging your own code.

When you get fed up of continually editing the code with new printf statements, and taking out ones you no longer need, then come back and we'll explain debuggers to you.

Salem 5,265 Posting Sage
if ( tree == NULL ) {
  return -1;
} else {
  return tree->height;
}
Salem 5,265 Posting Sage

Yes, this will take a while. Learning how to best use a new API does.

But FWIW, I think you've made a good start, you just need to stick at it.

Salem 5,265 Posting Sage

You could try concentrating on the rather simple task of understanding how to use code tags when you post.
You know, before actually moving onto something tricky like actually writing code.

It's not like the board goes out of the way to hide this information from you; I count at least 5 different places where you have an opportunity to learn, yet you missed all of them.

Is anything we say here just going to wash over you like some pebble on the shoreline?

Salem 5,265 Posting Sage

Well how did you get that far without RTFM?

> Moreover, I do not know how to do the "dump" procedure you talked about
It's pretty much the first step. Given a file format and an API, use it to read a few files, and print information about that file. It gives you practical experience of how real files are structured, which reading manuals seldom can.

Salem 5,265 Posting Sage

Carry on reading the documentation for rtflib perhaps?

Or create an RTF file how you want, then write a program to "dump" the RTF file so you know what the structure is, then repeat that in your program.

Salem 5,265 Posting Sage

Check your fingers for typos.
You're doing "ONE-PLUS-PLUS", not "eye-plus-plus"

> • the function is called in the main function as follows:
> nrOccur = nrACGOccur(geneticArray);
And do you do that?
Or do you just call it and ignore the result?

Salem 5,265 Posting Sage

Yeah, the first challenge is for you to read the introduction threads, such as

Our Software Development forum category encompasses topics related to application programming and software design. When posting programming code, encase it in [code], [code=syntax], where 'syntax' is any language found within our Code Snippets section, or [icode], for inline code, bbcode tags. Also, to keep DaniWeb a student-friendly place to learn, don't expect quick solutions to your homework. We'll help you get started and exchange algorithm ideas, but only if you show that you're willing to put in effort as well.
Our C++ forum is the place for Q&A-style discussions related to this popular language. Note we have a separate C forum for non-OOP straight C. Please direct C++ questions directly related to game development to our Game Development forum.

and http://www.daniweb.com/forums/announcement8-3.html

Salem 5,265 Posting Sage

Just print it out in reverse?
Or reverse it "in place" in the string it's stored in, then print it out?

Salem 5,265 Posting Sage

Start at the right, increment it by 1, then scan to the left to see what else can be incremented.

Salem 5,265 Posting Sage
Salem 5,265 Posting Sage

> Remember to include a function that displays your name and email address.
If I put "George W Bush" and president@whitehouse.gov, would you be smart enough to change it before handing it in?

> if anyone can pull this off that would be greatly appreciated
Pretty much everyone except you so far. But that's not the point, for the reason AD already stated.

I'm assuming that you already did the homework to read your name and age, and print them back out. How about modifying that slightly, since that covers the input side of your assignment at least.

Or did you sponge those answers off someone else and are thus now totally clueless. If so, just give up the course now to save everyone's time - programming isn't for you.

Salem 5,265 Posting Sage

Step 1, learn to indent code. Even programs as short as this are close to unreadable without good indentation.

/*
* File: sets.cpp
* ------------------
* This program deals with sets of lower case letters.
* This program computes the union and intersection of two sets. This program
* also checks if set B is a subset of set A and returns true if set B is a subset
* of set A and returns false if not.
*/

#include <stdio.h>
#include "genlib.h"
#include "simpio.h"

#define size 26

void init(bool set[]);
void initC(bool setC[]);
void displaySet(bool set[]);
bool unions(bool A[],bool B[],bool C[]);
bool intersection(bool A[],bool B[],bool C[]);
bool contain(bool A[],bool B[]);

typedef enum
{
    a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z
}
letters;
int main()
{
    bool A[size];
    bool B[size];
    bool C[size];
    printf("This program deals with sets of lower case letters. This program computes the\n"); 
    printf("union and intersection of two sets. This program also checks if set B is a\n");
    printf("subset of set A and returns true if set B is a subset of set A and returns\n");
    printf("false if not.\n");
    printf("\n");
    printf("Enter a list of lowercase letters as elements for set A.\n");
    init(A);
    printf("\n");
    printf("Enter a list of lowercase letters as elements for set B.\n");
    init(B);
    initC(C);
    unions(A,B,C);
    displaySet(C);
    initC(C);
    intersection(A,B,C);
    initC(C);
    if(contain(A,B))
    printf("B is a proper subset of A: true\n");
    else
    printf("B is a proper subset of A: …
Salem 5,265 Posting Sage

Since that was the reference implementation, meaning it's written for clarity rather than performance, then I guess you're stuck.

IMO, you need to spend more time looking at the code you have, and really trying to understand how it works. If something seems especially complicated, try rewriting it, and then use the test suite to make sure it still works.

This is weeks of work, not come back within a day "is there something simpler".

> Which part shuld be parallelize.
I dunno, it's your idea - what did you have in mind when you started this plan in motion?

My guess would be to look for outer-most for loops which operate on independent blocks of data. If twofish uses one block as part of the seed for the next block, then I don't think this idea will work out. Again, do you know how twofish works for this to even be possible?

Salem 5,265 Posting Sage

You've implemented a stack, so it's API is fixed at push and pop.
If you want to reverse it, then you pop everything off one stack (one at a time), and push it onto another.

Salem 5,265 Posting Sage

Or without having to store anything, read a letter, and output the corresponding number

Salem 5,265 Posting Sage

> This is my carreer on line.
Great, another seat warmer.

What are you going to do when you're given your first work assignment, try the same old technique of bugging other people to do your work?

Salem 5,265 Posting Sage

Open each one of them in turn?
Or open many of them at once?
- Because there are limits to how many files you can have open at the same time

If you list the files on the command line, then
while ( <> )
will process each file in turn

Salem 5,265 Posting Sage

Plenty of sites like it where it doesn't cost anything.

Salem 5,265 Posting Sage

Yeah, and yet another post where the noob didn't read ANY of the threads / messages which describe how to post code tags.

Salem 5,265 Posting Sage

Some of these
http://en.wikipedia.org/wiki/Hall_effect_sensor

And some of these
http://en.wikipedia.org/wiki/Analog-to-digital_converter

Look for them at your local electronics component supplier.

Salem 5,265 Posting Sage

http://www.daniweb.com/forums/announcement125-2.html
Here's some questions for you
- how are the switches and display wired to the processor?
- how are specific elements of the display selected?

Perhaps begin with something simple, say incrementing a digit every time a key is pressed.

It's not much, but you'll learn a lot, and not come across as a total sponge.

Salem 5,265 Posting Sage

Sure,
open F1,...
open F2,...

then
aLine = <F1>
anotherLine=<F2>

and so on

Salem 5,265 Posting Sage

http://technet.microsoft.com/en-us/sysinternals/bb545046.aspx
Filemon and/or diskmon would probably tell you what's going on.

Salem 5,265 Posting Sage

ANSWERED AGAIN in your other threads, just stop spamming the board.

Salem 5,265 Posting Sage

If you can't figure out from the first zip file that twofish.c is the algorithm, and tst2fish.c is a test wrapper with all the I/O you could ever need for it, then everything you plan seems beyond you.

happy8899 commented: Good!! +3
Salem 5,265 Posting Sage

Unless it's an array of chars, which if you regard it as a string, is conventionally marked at the end with a \0, then you're stuck.

Given void foo ( char *p ); Then

char a[10];
char *p = malloc( 20 );
foo( a );
foo( p );

As far as foo() is concerned, there's nothing standard to tell what kind of memory it is, or how big that memory is.

Further, this is also valid foo ( &p[5] ); which would almost certainly break any non-standard API which only worked on the result of malloc calls.

freelancelote commented: Thanks. The kind of answer I needed. +1
Salem 5,265 Posting Sage

Pass the size as a parameter. void foo ( char *buff, size_t size ); kinda thing.

Salem 5,265 Posting Sage

Twofish is unpatented, and the source code is uncopyrighted and license-free

Gee, what more do you want?

Nick Evan commented: >"Gee, what more do you want" Haz you got winning lotto numberz lol 1? ;) +10
Salem 5,265 Posting Sage

I still think it might work, if you can figure out a better way of clearing the interrupt other than through the = 0 method you have at the moment.

This is fine when you only have one interrupt, but if you have several, then the approach seems flawed to clear interrupts which haven't been processed.

Another point to remember is interrupt routines should do the least amount of work possible with the fewest resources possible.

Salem 5,265 Posting Sage

Clear the off-screen buffer
Draw into it
Copy it to the on-screen buffer

At any given moment in time, every pixel in the on-screen buffer is either the old pixel, or the new pixel. The on-screen buffer is never in a blanked state.

Salem 5,265 Posting Sage

> you can swap two ints with x^=y^=x^=y;
Yeah, and when it isn't an int, then what?
http://c-faq.com/expr/xorswapexpr.html

The same old hack gets posted time and time again.

If you actually use a temp variable, a modern compiler will typically recognise that it is a swap, and do something sensible. Which may in fact mean that it eliminates the temporary, and in some cases eliminates the swap (by keeping track of where the data should be, and currently is).
Plus, even the most pedestrian of programmers will instantly recognise it for what it is.
Plus, it's going to work exactly as expected for all data types.

The xor trick is basically smoke and mirrors, which few can even understand, and fewer still understand the traps which await.

You may as well have written
encrypt(x,y)
magic(x,y)
decrypt(x,y)
The optimiser has NO chance of figuring out just how smart you've been to achieve a simple effect, and will just fall back to doing exactly what you asked, on the assumption that you know what you're doing.

Salem 5,265 Posting Sage

> Is it possible to read a whole file at once with text files
Are you going to write some code to stop your machine grinding to a halt if someone attempts to load an especially large file (either accidentally, or on purpose).

Or put another way, what are you going to do with this file once you've loaded it?

Salem 5,265 Posting Sage

> my exiting code:
Really....
http://www.daniweb.com/forums/post702120-2.html
Try to reply to existing threads which cover basically the same topic as before.

In your loop, having worked out the distance between
6.324 32.707 50.379
5.197 32.618 46.826
ie, lines 1 and 2

Would you then need to work out the distance between
5.197 32.618 46.826
4.020 36.132 46.259
ie, lines 2 and 3

Something like

my @old;
open (IN, "filename.pdb") or die "$!";
while (my $line = <IN>) {
   chomp($line);
   my @array = (split(/\s+/,$line))[6,7,8];
   print "@array\n";
   if ( $. > 1 ) {
      # now work out distance between @old and @array
   }
   @old = @array;
}
close (IN);
Salem 5,265 Posting Sage

Well first we need to establish which processor / operating system etc you're using.
Because a MIPS answer for Linux won't do you any good if you're using an X86 for Windows.

Salem 5,265 Posting Sage

OK, so when you said "you'd ran it and it crashed", this was dis-information.

With linker errors, your program is going nowhere at all, and any mention of debuggers (which operate on the executable) is a moot point.

> g++.exe "H:\mylab3\Olympics.cpp"
I don't know how you set your project up, but it should have all 4 of your .cpp files listed as members of the project. At the moment, you only have one, and it thinks that's the whole program. Whereas in fact, it's just one of the classes.

From the command line, you would do
g++ Contestants.cpp Event.cpp main.cpp Olympics.cpp

In the make file log (after adding all the source files to the project), you should see something like
g++ -c Contestants.cpp
g++ -c Event.cpp
g++ -c main.cpp
g++ -c Olympics.cpp
g++ Contestants.o Event.o main.o Olympics.o

Salem 5,265 Posting Sage

Perhaps they've simplified it too much.
Though this question would be better asked on their forum, since they'll know a hell of a lot more about all the details.

Salem 5,265 Posting Sage

I think you need to post some actual text or images of these error messages.
Because that made no sense whatsoever.

Salem 5,265 Posting Sage

Can you show a small program where you call mygetch, and you have to press return twice

Salem 5,265 Posting Sage

The only thing the debugger needs from the linker is a decent symbol table so it can find stuff out for you, and relate that back to your source code in a form you can understand.

Salem 5,265 Posting Sage

What are T0IF and RCIF ?

Imagine an interrupt control register, with flags for various kinds of interrupts.

+---+---+---+---+---+---+---+---+
|   |   |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+
                          ^   ^
               USART   ---+   |
               TIMER   -------+

Setting both to 0 may be fine, if there is only ever one of them at once.

But to clear RCIF say properly, it would need to be RCIF &= ~0x02; Where ~2 evaluates to 11111101 (in binary), and the & has the effect of preserving all the other bits, and setting the required bit back to zero.

Salem 5,265 Posting Sage

> but for only a single file-not multiple files.
How is this any different?
Open your file of choice, click in the margin at the place you want to stop, and add breakpoint.
Or if you're using a command line debugger, then perhaps
stop in classname::method

Salem 5,265 Posting Sage

Well perhaps you could begin by using a debugger?
Do you even know what one is? I only ask because sometimes knowledge about even the existance of such things comes as a surprise to some people.

Or even telling us the sequence of commands which leads to a problem.
Say adding a contestant, then trying to remove them again.

Salem 5,265 Posting Sage

> them I am overwriting other data that I previously stored?
Yes.

> I am assuming that good programming languages take care of this so you dont overwrite your data?
Also correct.

Salem 5,265 Posting Sage

Well \d+\.\d+ would match a single floating point number in non-scientific format.

Salem 5,265 Posting Sage

1. There are copious examples on the net for anyone with the sense to go searching for them.
2. They won't do you any good if you're running your fossil TurboC on a nice new OS like XP or Vista
3. http://clusty.com/search?query=gsm+AT+commands&sourceid=Mozilla-search

Salem 5,265 Posting Sage

Well the first thing you need to remember is arrays start at 0, not 1.

2. Arrays can be initialised, not assigned, eg

RF_RXTXPAIR_SETTINGS RF_SETTINGS[2] = {
    {0xA8,0x2F,0x37,0x50,0xA0,0x00,0x41,0xF6,
     0x10,0x02,0x80,0x58,0x48,0x44,0x81,0x0A,
     0xFF,0xC0,0x00},
    {0xA8,0x2F,0x37,0x50,0xA8,0x00,0x41,0xF6,
     0x10,0x02,0x80,0x58,0x48,0x44,0x81,0x0A,
     0xFF,0xC0,0x00}
};
Salem 5,265 Posting Sage
Salem 5,265 Posting Sage

My example shows how to clear it.

Also, 20 is plenty for getting the algorithm to work. If you need more later, then it's a relatively easy change to expand it, knowing that you have something working already.

There's no need to add the complexity of say dynamic memory in the early stage.

Or as Sky says, use vectors. This is C++ after all.

Salem 5,265 Posting Sage

Exactly like I described in response to your other magic square thread.
http://www.daniweb.com/forums/thread147840.html

So long as your declaredmatrixsize is < MAX (in mine), you're good.