WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Assign more memory to the video driver?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I'm still struggling to understand, maybe it's just me, but your first example is throwing me of.

Look at it this way: (G1 && G2) || G3

You are looking for students in
1) Math-202 (G3) --OR--
2) CompSci-101 (G1) AND Economics-101 (G2)

Using language syntax makes the statement backwards. Use logic syntax like you did later with (G1 AND G2) OR G3. This takes it out ot the boolean syntax -- at least for me.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Sloppy... Just because it can be done doesn't mean it should...
After all, gets() still exists, doesn't it? ;)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

8080 Assembler

code    segment                     ; Start of the code
        assume  cs:code             ; Load code segment register
                org     100h        ; and set program up as a .COM file
start:  
        assume  cs:code

        mov     ax,     1           ; Start at 1
loop:
        call    outdec              ; Output the AX register
        inc     ax                  ; next value
        cmp     ax,     10          ; Above 10 yet?
          jle     loop

        mov     al,     0
        mov     ah,     4Ch
        int     21h                 ; Exit 

; ******************************** ;

outdec:
        push    ax                  ; save AX
        mov     bx,     10          ; divisor
        mov     cx,      3          ; # characters
convloopd:
            mov     dx,      0      ; zero high word for div
            div     bx              ; divide by 10
            add     dl,     30h     ; convert remainder to char
            push    dx              ; Save character
            loop    convloopd       ; do it til cx = 0
        
        mov     cx,     3           ; start another loop
outloopd:
        pop     dx                  ; get the character
        mov     ah,     02h         ; output character fcn
        int     21h                 ; output it
        loop    outloopd

        mov     ah,     02h
        mov     dl,     ' ' 
        int     21h                 ; output 2 spaces
        int     21h

        pop     ax                  ; restore original number
        ret
code ends
end start
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If these are actual formulas:

Groups of Groups
GG1 - (G1 && G2) || G3
GG2 - (G2 || G3) && (G1 && G4)
GG3 - (G1 && (G2 || G3)) || G5

then
GG1 = G3
GG2 = 0
GG3 = G5

Now I want to be able to determine all the users that satisfy the conditions for GG1, GG2 and GG3. So based on the above examples, we have:

Users in GG1: U1, U2, U5
Users in GG2: U5
Users in GG3: U1, U4, U5

How can I algorithmically determine this?

AND the user with the GGroup. If != 0, user is in the group.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

ForTran

integer i
        do 100 i=1,10
100     write(5,200) i
200     format("i3")
        end
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Is there a simple way to create multi-line tool/tip text boxes ... nothing special, no balloons or anything, just multiple lines ???

Doesn't look like it. I tried an obvious way -- at least to me -- and it didn't work. In form load change the tooltip using

Text1.ToolTipText = "this is another test" + vbCrLf + "the second line"

Didn't work... The tooltip 'parser' doesn't process vbcrlf as a CR-LF. They are undefined characters so they came out as boxes.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

if you don't know where to start, here's a hint

You forgot the return:

int main()
{
    // put your code here

    return 0;
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

And, cout is the C++ output command, not printf() , so you don't need stdio.h any longer.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

ok thanks problem solved, i declare a global variable char b[8]; and make char *bin=b point to b, it works. but i am just wondering making bin points to b does nothing but it works can someone explain why ??

Pointing bin to b does nothing? I though it points bin to real space...

A pointer needs to point somewhere. But when you declare a pointer using char *bin; where is it pointing to? All it is is a holder of an address but no address has been loaded.

Then when you use bin = b; the address of b is now loaded, and bin points to the first byte of b. And life is good.


Now for your specific program, an easier solution is available. If you change char *bin; to char bin[9]; your problem is solved. In the first instance, bin is a pointer and must point somewhere. In the second, bin points directly to the array, so it is used as a direct pointer without changing any of your other code. And it must be 9, not 8. Remember, a C string must end in a 0, and a byte contains 8 bits -- therefore 9 values are required.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

The first problem I see is you defined a pointer bin but you never created space for it. A point simply points to space, yours points nowhere so your binary characters are going somewhere you really don't want them to.

Second problem is strrev() is not a standard function. You might be better off simply printing from the end to the beginning.

Dave Sinkula commented: Yup. +7
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Wow how old are you ? I'd expect to find you at slashdot rather than daniweb.:cheesy: I've read about those days, you submitted your code and didn't get output until that afternoon or maybe the next day!

Old.... But we were on a PDP-10 Timeshare machine. Looked like the command line today -- compile, run, fix, repeat. It was the batch people that had to wait -- but only a few minutes on this system. Batch means those punch cards -- even older than me... My record collection used to be on punch cards... :eek:


We're obviously talking about the same thing from different angles. I thought you were talking about the tool -- Dev-C, MSVC, etc., not the knowledge about how to get the job done with the language.

Hmmm you still havn't convinced me yet I still think you're attaching too much importance to the language, isn't it more about knowing how it all works. Essentially languages expose the same things variables, loops and decisions. I mean my own experience has been the language is easy, what I have found hardest *exactly is* getting from code to program.

If you don't know the language, you can't get the job done, no matter how much you know about "how it all works". But then again, you have to know how it all works to know what to code...

The real craft for me has been learning how to organise my header and class files, ...

hollystyles commented: Worthy posts +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

This is a bit basic but might help.

A bit basic! LOL That's a good one!!!! :D

See, BASIC is the language, so it struck me funny.... Oh, never mind!!

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

This all started over WaltP dismissing dilips' pre-processor macros as "undefined behavour" and not a real problem.

My arguement is it could be a real problem, and very possible in a large project. And the behaviour we have tested is clearly documented for the Gcc compiler and in the standard (courtesy Wolfpack)

I concede that it's is no longer undefined behaviour -- thanks to Wolfpack too. I didn't actually look up the standard to see. I made an erroneous assumption. (but it was a logical assumption :))

And I never said one should use only ONE compiler, but I stand by the notion you should take the time to know it well...

Still disagree. Irregardless of the compiler, you need to know the language. All you need to know about the compiler is how to start the compile process. You don't need to know how it parses, how it preprocesses, how to debug (although it can help admittedly), nor any of the esoteric stuff that's packaged in.

Now if you mean by 'compiler' the IDE editor (which is not part of the compiler but a surrounding package containing the compiler) I still disagree. A bare bones basic editor (Notepad) is certainly enough. I still remember editing on teletypes -- not even a screen existed -- and we did all right. But the help an IDE gives you is a big benefit -- but not required to be a top-knotch programmer. It all comes down to knowing the language …

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

But use DevCPP at home. Maybe code that works in DevCPP will work in TurboC, although not the otherway around (not sure about that but stick with code that works in DevCPP as much as possible).

As long as standard C is used, Turbo and Dev are compatable. There is nothing wrong with Turbo C (even down to Turbo V1). It implements the same stuff the "current compilers" have implemented. It just has a few more "enhancement functions" that are not in the new packages (interrupts, graphics, screen capabilities) and it compiles in 16 bits. Although I agree a school should be using an up-to-date compiler.

Saying Turbo is crap is like saying the Dick Van Dyke Show is crap because it's a 1960's show. It's still better than most comedies on TV today... :)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hmmm...

Yes you should know the language well, but without a compiler (standards compliant or not) it is useless.

The language is just the wood, it is the tool and the "in depth" knowledge of it which produces the craft. A cabinet maker chooses his tools very carefully and lives with them until they become extensions of his own limbs. Standards are important and have their job to do but IMHO you certainly shouldn't rely on them they change often, will always be open to interpretation and sometimes blatantly ignored.

Completely disagree. The language is the tool. The compiler is the wood. With knowledge of the language (how to make a cabinet) it doesn't matter what wood (Borland, Dev-C, MSVC...) you use. The compiler simply gives you the finished product. Each wood has it's own distinct color, grain, but the functionality will be the same with the proper design. Sometimes the wood can have a knot in it that can be a detriment ( system("pause")/fflush(stdin) or an enhancement getch()/kbhit() to the final product.

This whole metaphor is interesting.... and slightly inaccurate. But it illustrates our points, I guess :)

IF any construct or any stmt for eg. fflush (stdin) suppose would be defined under one compiler it would make really less sense to adopt it if it results in undefined behaviour on other compilers. (though it really is undefined under all implementations)

Assuming I'm reading you correctly, your parenthetical statement is incorrect. "it [undefined behavior] really is undefined …

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hi WolfPack,

ok..I've got what do u mean..and I already try it n it works..but..I still need to type the filename right?..If possible, I just want to run program.exe only but then it can read all the files inside the same directory.

This may not be necessary. If you use the filename *.fil, in the version of Unix I used the command line was expanded to include all .fil files. Then you only have to loop through the command line parameters if Red Hat works the same. Give it a try with something simple:

int main(int ac, char *av[])
{
    int parm=1;
    while (parn < ac)
    {
        puts(av[parm++]);
    }
    return 0;
}

See what happens. Add the headers, of course.


By the way, using scanf() to read strings is just like using gets() -- you should really us something safer like fgets().

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I would put this under "undefined behavior"

But it is clearly defined in the document to which I posted a link. It is important to understand in great depth the tools you work with. It is very possible for a large project to have potentialy conflicting pre-processor directives- not as simplistic as the example postulated here but no less poignant - like this.

But is that defined only for Dev or is it defined in the language standards? If only in Dev, then it's a bad thing to rely on. When you change compilers, according to your suggestion, you must then start the "great depth" learning curve from scratch as you try to track down why your programs no longer function correctly.

IMO, you need to understand the language in great depth, not the tool's version of the language. Try to avoid compiler-dependant functions and implementations whenever possible. Wolfpack has the correct idea, and that is by quoting the C++ Standard

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I would put this under "undefined behavior" and assume defining a to be b then b to be a to be a bad practice. Therefore I would abandon the concept of understanding what the compiler would do and move on to a different problem -- one that makes sense...

Just my 2 cents.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
Salem commented: Nice link to the CLC FAQ - Salem +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I am novice of c++.
How to set co-ordinates of console using c++?
e.g. what to do if i wanna print pyramid of astericks at the center of the screen.
should i use gotoxy(x,y) function to go to the center of the console?

No. You should print the correct number of spaces and newlines to center your 'image'. gotoxy() is very non-standard and does not exist in most compilers.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I agree. Go with C++. C# is for a specific arena so you would be better off IMO learning a general tool.

C is easier, but C++ is becoming more universal, and will be easier to learn if you don't already know C (again IMO).

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

A better idea is to invest in Microsoft Visual Studio, so you can use the software everyone uses and is familiar with. It also contains other programs, for example visual basic which is a pretty fun language.

I disagree. First, everyone doesn't use it. Second, DevC at least follows the C/C++ standards. VS-C++ only somewhat follows the standards.

Unfortunately Visual Studio is pretty expensive, so you could just stick with bloodshed dev-cpp or Borland (is that compiler free? I dunno).

Yes, Borland 5.5 is also free, and my compiler of choice, FWIW...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Set up a loop that takes 2 characters at a time, convert those 2 characters to a hex value, and output as a character.

To convert 2 chars to hex:

subtract '0' from first giving X. It's now binary.
if X > 9, subract 7 -- it's now hex.

Do the same with 2nd character, making Y

HEX = (X << 4) | Y which shifts the second 'digit' X by 4 bits (multiply by 16), then adds in the first 'digit'

putchar(HEX) outputs the character.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I'd prefer:

#include <stdio.h>
int main()
{
    unsigned char a[100];     // unsigned to make all values positive
    int len, i;

    printf("Enter the string");
    fgets(a, 100, stdin);     // safer than scanf()

    i = 0;
    while (a[i])              // use 'end' of a string as your guide
    {
        if ((a[i] >= 'a') && (a[i] <= 'z')) // check if a letter
                                            // could use isalpha() too
        {
            a[i] += 13;       // encrypt
            if (a[i] > 'z')   // check if beyond alphabet
            {
                a[i] -= 26;   // convert back to beginning
            }
        }
        i++;                  // next character
    }        
    printf("%s", a);
    return 0;
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What are you guys taking about? The original request is:

how would i go about converting a string value to HEX
ie
char name[10]="STEPHEN";

Convert name to HEX

What does this mean?
1) "STEPHEN" is not a number so it can't be converted to Hex
or
2) "STEPHEN" is a string of characters that each have a Hex value. Do you mean add these characters to get a value?

Maybe an actual example would be in order. After the conversion, what should the Hex value of "STEPHEN" be?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Can you please point out what needs work with the scanf's and all.. I can't exactly locate any problems.. like i said I dont' have the program to test it out..

You should download a compiler then. Try Borland's free compiler or Dev-C++

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Another option is to read a good sized chunk of the file (5K, 1M, 10M) and operate on the data while it's in memory. When you have 10% of the chunk left unprocessed, move it to the beginning of the buffer and read the next chunk.

Reading a buffer at a time is much faster than a character at a time.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I'm going to assume csgal's tutorials helped on the programming.

One thing you will eventually need to do (like right now) is start formatting your code. Indent after ever { and unindent when you get to every }. Also every if statement is wrong. = is the assignment operator. == is for comparison. And remove the ; because that ends the if statment, making it useless (it executes nothing). So instead you need if (d == 1)

I know it seems like too much but everywhere I look i see cout and cin when I use printf and scanf @_@, Please anyone help me.. I don't know where else to look

You are using printf() correctly because you are writing C code, not C++. scanf() is also used correctly for the same reason, but the sooner you start using a different input form (fgets() with sscanf() for example) the sooner other headaches will go away, assuming your head already hurts. Check out Dave's tutorial for more information: http://www.daniweb.com/tutorials/tutorial45806.html
By the way, cin is the C++ equivalent of scanf(), cout is printf(). So for reading code they are interchangable.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

And how does the program read the value n2?

The best way to answer these type of questions is to just try them:

int main(int argc, char *argv[])
{
    int param;

    printf("argc = %d \n", argc);
    for (param=0; param < argc; param++)
    {
        printf("%2d)  %s \n", param, argv[param]);
    }
    return 0;
}

Write a small program to test only the problem in question to understand how the specific technique works. Then once you understand it, go back to the program you're working on and incorporate what you've learned. This way you may in fact write 5 small programs instead of just one big one but you'll understand the specifics better and faster. You will have your information in minutes instead of hours or days...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

About void main ():

In addition, check out this

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

In my TurboC setup I have a TURBOC.CFG config file in the directory with the executables. It contains

-Ic:\lang\TC\INCLUDE;c:\lang
-Lc:\lang\TC\LIB;c:\lang
-v

-I finds any headers in either directory listed.
-L
same for libraries.
-v
to add debug code to the compile.

I have the compiler in C:\lang

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

7 * 3 * 3 * 2 * 2

Pi R Squared
No Pie R Round
Cornbread R Square

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Nosferatu

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Kotch

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Well, you have a hard uninteruptible loop of 39,321,600 iterations. How long is this going to run do you think? And once it starts, it's going to run until completion. Remember, you are in an interrupt. The way I remember it, an interupt will not let the normal programs run until it's finished.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Since all you are reading is a character, use getchar() . But remember that you did hit the ENTER key too. You therefore have to clear the buffer. So when you read a character, use something like

whatever = getchar();  // at least one character left in the input stream
do
{
    dummy = getchar();    // read another character
} while (dummy != '\n');  // stop when newline is read
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I want to learn C+ but i want to start with a simple compiler. I have access to Borland C++ and Visual studios.net but they are way to overwhelming. Can some body give me names of decent simple programs that I can learn with.

All the compilers are going to be fairly similar. They handle C++. It seems what you are asking for is a compiler that doesn't have all of C++ implemented. Not recommended. Just pick a compiler you want to learn with and use it. You don't need all the bells and whistles in the compiler, you just need to know how to:
1) create a project
2) type in your program
3) edit more than one file in your project
4) compile the code (icon or keystroke)
5) run the code (icon or keystroke)

All the rest you can mostly forget about until you're ready.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

cuz system("pause") holds the screen , even after i have input everything i need to input into the black screen.

I don't understand. How does cin fail to "hold the screen"? And where does the "black screen" come from using system("pause")?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Is there a better way to go about this than what I am trying here?

Yes. Read in all the words to ignore into an array.
Then read in a word at a time from text.txt and see if the word is in the ignore list.
If the word is not in the list, output it. If it is, don't.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

i always use system("pause"); to hold the black srceen open. but it has no effect. u can reply to this if you have any other suggestion but i wont be able to answer for another hour or so...but pls any help will be greatly appreciated!

Why use system("pause"); to call the operating system and execute an OS command when a simple cin will stop execution until you press ENTER? Isn't cin actually part of the language itself?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

One array and two indecies. One index points to the empty position for the next character to be added. Other index points at the character to be removed when needed. When either getst to the end of the array, reset to beginning.

You need to decide when the queue (this is the name of this structure) is full and empty.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

First thing you need to do is clean up your formatting so you (and we) can see your program flow. After every { indent 4 spaces. When you get to the } unindent.

Look up the syntax for this statement:

if ((multand<=32767) && (mult<=32767));

If this and that -- do nothing. The ; ends the statement. Do you want to execute something?


You claim

Add _(2) together _(2) times 2+2+2+2=4 <--(this is a problem...its not supppose to do that and I'm not sure how to fix or write it)

I assume you mean 2+2+2+2=4
Look at your code:

cout<<"Add "<<multand<<" together "<<mult<<" times ";
cout<<multand<<" + "<<multand<<" + "<<multand<<" + "<<multand<<" = "<<result;
cout<<endl;

How many times do you output multand?


What is this line supposed to do?

response =='Y' || 'N';

I think I know what you are trying to do, but maybe you should explain this line.

system("CLS");

Remove this -- it's only in your way at the moment. If you really think you need it, add it when the program is running.

else if ((multand>32767)&&(mult>23767));

Same as the above if statement

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

use getline()

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Recently I installed Visual Studio 2005 .NET on my computer. I wrote a Win32 program. But my program doesn't run on PCs that doesn't have Framework 2 installed on.

Gee, why does it not surprise me that you can no longer just build a program and run it anymore?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Thanks. I didnt think to use a matrix like that, so that i dont have to reference every solution individually, i can reference by number (which is sortof what i was looking for to begin with). I wouldn't need getSolution as a function, would I? Since it would only be called once in the program (or atleast only typed once)?

Use the function. It's modular and better programming practice.

Unless it has something to do with static?

Nope.

What does static do?

When used with a variable in a function, each time the function is entered the variable retains the value from the last time the function was used.

Is it possible to return an array in a function, or only its pointer?

Pointer...

And I still would like to know (even though i have no immediate need now) if its possible to store an array with {1,3,6,2....} while not initialising it.

Not a clue what you are asking. In order to get the values in the array it must be initialized somehow.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

in the code i see that it sorts accodring to "code", how can i modify the program so that it sorts even according to "subcode" and "brandcode";
i.e., code as primary key, subcode as secondary key and brandcode as third key; here, each code has a subcode and each subcode has a brandcode.

If idiff = 0 check the "subcode". If that is equal, check "brandcode".

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Ahhh, fergitit.... ;)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Try

#include <string>

string.h is not meant for 'C++strings', it is for char* or 'C-strings'

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Recommendation:

Unless you must leave floats and doubles in the program, settle on one or the other. Doubles would be best.