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

You will see the problem immediately if you format your code better:
Put each { and } on separate lines
Every line between corresponding { }'s should be indented 3-4 SPACEs.

For example:

int function(int val)
{
    int rtn, tmp;
    if (val > 10)
    {
        tmp = val * 4;
        rtn = tmp + val;
    }
    else
    {
        tmp = val * 6;
        rtn = tmp - val;
    }
    return rtn;
}

Errors

--------------------Configuration: DLL - Win32 Debug--------------------
Compiling...
Main.cpp
error C2109: subscript requires array or pointer type
error C2065: 'godmode' : undeclared identifier
Error executing cl.exe.
Creating browse info file...
DLL.dll - 2 error(s), 0 warning(s)

Please let us know what lines these error are on. Just telling us the errors does not give us enough information (although I did find one -- this time)

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

You should at least ell what game your talking about. This is bound to make no sense to almost everyone.

He did. Halo.

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

Try it, JRM, enter 12A and see what happens. Be sure you put your cin in a loop.

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

I working on a program that summerizes text documents and I need a way to find the length of the longest and shortest lines in the file and display it in a log file. I've already done a character count and line count.

int main (void)
{
...
    while ((c = fgetc(file)) != EOF)
    {

Instead of fgetc() use fgets() to read an entire line. Then you can add a loop to continue doing the part you have already done, and you can check the length of the line for the min and max.

Or start a counter to count each character and when you read the '\n' test that counter against the current min & max. Then reset the counter to 0 and continue.

I recommend reading the first line and set min & max to the length of that line. That would be a good starting point.

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

Hi

HI

I have a text file which has 4 heading which will constitute the number of columns and based on values an array has to be populated.

So you know there are only 4 headings, right? Do you know how many values there are? If only 9 you can simply set up an integer array like int values[numheading][numvalues]; Then it's a simple matter to initialize the entire array with, say, -1 to represent NULL. Then when you read in each line you can assign the value read to the proper array location.

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

First you have this:

void WriteMem(DWORD MemOffset, DWORD DataPtr, DWORD dataLen) {
...
  }
  void EnableHack(BYTE* AddrToChange, BYTE* To, DWORD len); {
   for(DWORD i = 0; i < len; i++) 
    WriteMem((DWORD)AddrToChange+i, (DWORD)To+i, 1); 
  }

and the recomendation was

>> void EnableHack(BYTE* AddrToChange, BYTE* To, DWORD len); {
remove the semicolon

Now you have:

void WriteMem(DWORD MemOffset, DWORD DataPtr, DWORD dataLen); {

What changed in the line (and more importantly, why did it change?)

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

I have a perfect hawk eyed vision :D

But not in your deams -- you need some dream-specs...

PS: BTW Mr. WaltP you have an excellent and awesome avatar there, unparalled. Kudos to the one who made it ( dont tell me it was you :eek:)

OK, I won't. But it only too a couple minutes. I got the picture here. Click on one of the "dynamic images" on the left. It's really kool!

th black and white thing is odd really

my dads friend had a heart transplant and now he dreams in back and white

Sounds like he got a bum tuner -- er ticker...

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

You cannot compile FORTAN code with a C++ compiler...:rolleyes:

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

Bump! Please help! My code is due very soon!

This is not a chat forum. Don't bump your posts. It's not necessary and we have lives outside the forums. Plus, your lack of planning is not an emergency for anyone but you ... sorry. We'll get to it when we get to it.

What it's supposed to do is take in a probe. If correct, it says how many probes it took to get the correct answer.

If wrong, it says how many letters were right from the secret word..

I tried compiling and stepping throguh, but it gives me wrong results. For example, I type in a probe, and it prompts me to type in a nother one without any output in between.

ex.
How many rounds do you want to play? 1
Round 1
Probe: aback
Probe: abet
3

Can you see what's wrong?

for (int a=1; a < rounds+1; a++)
    {
        cout << "Round " << a << endl;

        [b]// you play one round and throw away the result...[/b]
        playOneRound (myRand(10));

        [b]// ... then you play another round and output the result[/b]
        cout << playOneRound(myRand(10))  << endl;
        [b]// Therefore it looks like you input twice[/b]

    }

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

Please format your code and use whitespace. It's practically unreadable in in't present form

#include "matrix.h"
Matrix solve (const Matrix& A, const Matrix& B)
{
/*  solve A x = B and return the answer.
    It is assumed that A can be factored without pivoting.
    The factors are not saved
*/
    if (A.row != A.col  ||  A.row != B.row )
        error ("Matrix solve: incompatible sizes\n");

    Matrix C(A), X(B);         // local copies of A and B
    int i, j, k, cr=A.row, xc=B.col;
    double a, b;

    // First preprocess C
    for (i = 0; i < cr; i++)
    {                        // for each row of C
        if (C.m[i*cr+i] == 0.0 ) error(" zero divide in solve ");
        a = (C.m[i*cr+i] = 1./C.m[i*cr+i]); 
        for (j = i+1; j < cr; j++ )     // normalize the current row
[b]etc...[/b]
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Unable to correct this

[b]int[/b] main()      // manutd is correct
{
char string[20];
char *aString=string;
function (aString);
}
void function(char *name)
{
cout<< "enter name";
cin >> name;       // name is already a pointer, remove *
cout << name;
}

And learn to format your code. It will help you as your programs become larger. Each line after a { should be indented about 4 spaces. The } is unindented those same 4:

int main()
{
    char string[20];
    char *aString=string;
    function (aString);
}
void function(char *name)
{
    cout<< "enter name";
    cin >> name;       
    cout << name;
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
fgets(temp, 80, stdin);  //get data
	input = strtod(temp, &endptr);
	
      char *newline = strchr(temp, '\n'); /* search for newline character */
      if ( newline != NULL )
      {
         *newline = '\0'; /* overwrite trailing newline */
      }

This works if you type exit it would exit the loop.

Yes this works, but it's very inefficient. As you say, wee, think about what is in temp and where it came from. Where could the '\n' be? Only at the end of the string. Why search?

fgets(temp, 80, stdin);  //get data
input = strtod(temp, &endptr);
length = strlen(temp) - 1; /* get the end of the string */
if ( temp[length] == '\n' )
{
    temp[length] == '\0';  /* overwrite trailing newline */
}

And in C, defining the variable in the middle of the code is not legal. This isn't C++ ya know... ;)


And kie, please learn to format your code. It will help immensely as your programs get larger.

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

Same here, all in black and white. And what more, the dreams are hazy, cant see them very clearly.. :cheesy:

Wear your glasses to bed then. :rolleyes:


I've heard if you dream in color you're insane. Says a lot about the people here. If you only dream in black and white, you should be banned!!!:twisted:

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

of their ancestral

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

burnt their fingers

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

Won't her software be incompatible with my hardware? Cos Girlfriend 1.0 was released, how many ..., 20 years ago?

Experience is sometimes a good thing...

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

Please learn to use Code Tags. Also learn to properly indent your code and use whitespace. It is unreadable in it's present form.

Based on the information you gave about your code, that's all I've got. If you have a ploblem and need help, give us some details, including what the problem is, what the program should do, what it does do, and where the problem is.

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

I considered the idea of converting all input to int (from float or char) but I have had little sucess with my research with this so far, converting an input value to int from any possible other type (float, char, double, etc.)

Any advice, direction, or resources on this matter would be well appreciated. Thank-you in advance.

Are you sure you're ready for this? It's somewhat complicated ;)

First of all, your input must be in char* or string. Then you must check each character entered to see if it's the correct type of value -- like all digits for int. If there's a bad character, decide what you need to do -- convert what you can or call it an error and try again.

If all is well, convert the string and return the proper value.

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

Jeez, lot's of bad ideas here....

Read in all the numbers into an array (ary[]) first, do NOT store the -99. If you enter 5, 8, 6, 3, -99, your count should be 4, not 5.

Then set lowval to your first element, ary[0] because it could be the lowest. Then loop from 1 to count for the test.

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

I'm an Easy Rider, too.

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

go to hell

in a handbasket

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

Hmm...What have you been smoking lately Wolfie ?

So who's the one with the smoking avatar? :p

Honestly I haven't got anything better to do in my freetime.

Somebody needs a girlfriend... I can give you a discount on a slightly used Girlfriend 1.0...

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

So my questions would be:

1. is my general idea alright?

Yes. But you should pass in the hex array. C cannot return a character array. Also, format your code. Indentation is extremely important at all times. So is spacing between terms, like:

while (fscanf(a, "%d", &broj) != EOF)

Much easier to read.

char dek_hex(int m){    /* this is where my problems start. No matter
                           how I write the function, I keep getting all 
                           kinds of error messages */

Unless you post something you've tried, we have nothing to help with.

2. what should my function look like?

Basic idea in my previous post.

3. can it be done without a function?

Yes it can. Considerations:
function: Modularizes the program, easier to reuse the function in another program later. Somewhat easier to debug.
non-function: Not passing the hex array is a minor benefit.

like I mentioned in my previous post, printf() family of functions, which includes ssprintf(), will convert int to hex using "%X" .

Wouldn't this nullify the purpose of understanding how decimal to hex works? ;)

~s.o.s~ commented: Well said Mr. WaltP -- ~s.o.s~ +7
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

down the stairs

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

Each byte is 8 bits. 8 bits can hold from the value 0 to 2^8th (2 to the 8th power) or 0-255. Therefore 4 bytes can hold up to 2^(4*8) or 2^32nd. That's 4,294,967,296.

Now these are for unsigned values. Normally, though, values are signed which means 1 bit is used to indicate positive or negative. Therefore 1 less bit. In this case:

8 bits hold the values -128 to 127 (2^7th). 4 bytes can hold up to 2^((4*8)-1) or 2^31st. -2,147,483,649 to 2,147,483,648.

A better explanation is here

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

I had Wife 1.0 and Girlfriend 6.0 on my system. Everything was OK until they got loaded in memory at the same time. Ever since my system crashes and I have to keep upgrading my Attorney program -- I'm now on 75.4

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

I've used HyperSnap. It had the most options I needed (included command line invocation). The author is also very responsive to bugs and requests.

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

I can't find the spot that shows comments for reputation. Where did it go?

Found it -- Control Panel.... :rolleyes:

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

You REALLY REALLY need to format your code. Indenting is extremely important.

At row 378 I have started search function, but I'm not sure where to go with it from here as far as setting up the recursive alg. part of the code

First thing is read in what you want to search for correctly.

At this point in the program do you know exactly how many entries are in arr? If the array is not full you should pass in the number of entries.

Then call your recursive seach function (the function called seach() cannot actually be the function) passing in the array and the index to the middle entry (I'm assuming you are doing a binary seach -- what did you use before?)

Then in the function, test the entry pointed to with the name looking for and call the recursive search function again using the binary seach algorithm. Keep calling the function until
1) you find the value -- return with the index of the value
2) you have exhaused the search -- return with -1

If you need the binary seach algorithm, check here

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

This will load the hex values from smallest to largest:

make a character array ([I]hexval[/I]) about 10 characters long
set whole array to spaces
set [I]hexval[9][/I] to '\0'
set [I]hexptr[/I] to 8 -- this will point into [I]hexval[/I] to load the hex chars.
Read a line into an integer ([I]intval[/I]) -- that's base 10.
Loop until that integer is 0:
    set [I]hexval[hexptr][/I] = [u]remainder[/u] of [I]intval[/I]/16 
    add 48 ('0') to [I]hexval[hexptr][/I]  -- this converts the integer value to a digit character
    if [I]hexval[hexptr][/I] > 57 ('9') add 7 -- value is now 'A' - 'F'
    decrement [I]hexptr[/I]  -- to load the next hex digit
    divide 16 from [I]intval[/I] -- to remove the hex val we just loaded
    End of loop
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I can't find the spot that shows comments for reputation. Where did it go?

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

songnum is a variable, that's where my choice for a song is stored into it.

But I've solved all of that. My program works how I want it to, except for one thing.

When I add a song, I want it to add it to the right column, and do the time stuff, only if there is enough time left (remaining is bigger or equal to the time of the song). I have it so that it won't add it to the right column, and entering the number of the songs for the ones already on the right column does subtract the time, but the songs don't move back. I think know why they dont' move back. Because in a line of code I have it set so that it prints them on the right when the song's time is less than or equal to the remaining time.

But, one odd thing I've noticed, is that lets say I move the last three songs to the right, this will take up almost all the remaining time, only leaving 1:48. If I try to add another song bigger than that time, it won't add it, and it won't display it on the right, that's cool. However, when I try to remove songs from the right. It won't do it.

Like if I chose to remove one of them, it'll do the math right in the time displays, but the song will stay on the right. Why is that? If I enter …

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
#include<stdio.h>
int main(void)
{
char letter;
char *pletter;
pletter = &letter;
printf("%p", &letter;
putchar('\t');
printf("%p", letter);
putchar('\n');
puts("Understand?\nWhat is the right way? it is 4bytes different");
//*allows the value to be altered by the base adderess
//&lets a datatype to value by its adderess from another datatype takes 2 datatypes of same size(bytes)
return 0;

For future, please don't ask your question in the code. Ask in the text area. It took me three times longer to decypher your question...

The reason is that it's is simpler for the system allocate the variables on 4-byte boundaries. So if you have a char* array of 6 bytes, you'll see an 8-byte difference.

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

I just remembered, there is a way to compile the BGI drivers into object code which then can be linked directly into your .EXE file. That's how I've done exactly what you're attempting.

I forgot how to do it (it's been years) but if you have the manuals, check in there. Otherwise try searching for BGI+BORLAND+OBJECT+FILE see what turns up.

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

In your in[ut function, if you get one of the characters you want to ignore, just go back and input another character. It's just an addition to your already complex input loop.

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

I repeat:

Output values that are key to the operation of the code (like a, b, and c) at important decision points to see what values they contain.

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

English
This thread is a year old, why are you posting in it ?

Dutch
Dit onderwerp is een jaar oud, waarom reageer je hier op?

;)

English: Because it is there!
Piglatin: Ecausebay itway isway erethay! :p
Oppish: Bopecopausope it is thoperope! :rolleyes:


Oh, and
Spanish -> English -> Italian -> French
NO NO NO NO! :p

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

hey guys
i need your help please

Duhhhh, we don't gots no intel'gint peeple here...

really urgent

OTay, I get rite on it! After all, your need is more important than mine...

can u give me visual basic codes for
1- a program that calculates the greatest common divisible(divisor) by only (while) statement ...plz guys ! only while or if statements !

Ummm, better wait til the smart guys show up. I can't write code for you - it wouldn't be your work. Even us dummies know the difference.

2- a program that prints the following nubers also by only while statement
0,1,1,2,3,5,8,13,21,34

Gee, talk to Fibonacci. It's his sequence.

as u can see 0+1=1, then 1+1=2 then 1+2=3 then 2+3=5 then 3+5=8 and so on ...

Oh? that's kool.

please guys help me

i really need your help

Please don't insult our intelligence like this.
#1: your title is offensive
#2: nothing is urgent
#3: Unless you try, we can't help. We're not going to do your work for you.

plz let be clear cause i am a beginner

thanks alot :) :cheesy:

Obviously :rolleyes:

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

Does we need turbo c software to run turbo c exe file?
Hmmm sounds wierd! I wrote a program called chart.c in turbo c which is two header files like bimap.h ,xyz.h.When I compile,chart.exe is created.when i run chart.exe in some other machine, its not running unless tc sofware and those two header files is placed in the system.Can anyone tell me why it happens and how to make one single exe file without all these headerfiles and tc sofware.

No, you don't have to have the source code files on the machine. The .EXE is all you should need.
What happens when you try to run it? Without the "what happens" there is no way we can figure out the "why".

Why use Turbo C? Try downloading Dev-C++, Code::Blocks, or if you're into the command line, gcc.

No need to suggest a new compiler. Turbo C works just fine. It isn't broken just because it's old.

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

its a task dat's very difficult...i have to create my own prog. lang. for finals...can anyone plz help me?:eek:

Yes we can. But you have to figure out what the language looks like and how it should work, and we can suggest corrections as you code it.

And please don't change the color of your posts... Keep it black.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
int* intArrayPtr;
intArrayPtr = (int*) malloc(someSize * sizeof(int));

malloc always returns a void* which you can typecast to be anything you want to...

See this...

IOW, don't cast malloc()

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

Don't need the compound if. if ((intNumb % intDivider) == 0) will suffice.

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

Output values that are key to the operation of the code (like a, b, and c) at important decision points to see what values they contain.

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

It's only crappy DOS compilers which ever had this,

What about crappy MSV-whatever? It allows void main() without a problem to this day, doesn't it? And OS/2's compiler didn't complain, either, if memory serves.

...presumably because DOS was so crappy at dealing with the return value that nobody ever cared.

I cared -- and used the return value all the time in .BAT files.

All real compilers only accept int main, which is the only standard you should be worrying about.

Absolutely... Anyone tells you different, smile knowingly, and deck them! Then have them talk to Salem.... :twisted:

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

What is the songnum[] array for?
What is in it when this function is started?

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

Now, this part is my main problem. I'm trying to make it so that in my main function, when I select the songnumber of a certain song, it displays an "*" in front of the number. I don't understand how though.

If you think about it, when can if(select[songnum] == !select[songnum]) ever be true? Isn't this the same as if(val == !val) ?

Maybe something like if(songnum == i) is what you're looking for?

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

:sad:

:mrgreen:
don't bump posts. When someone that can help comes along, they will. :evil:

I'm also having a problems with this section of my function. I am currently using a for loop, when it should be a while loop. The commented while loop there is what I'm trying to do, but it won't work, the program won't display anything.
...

for(index=1; index <9; index++)
     /*while(status !=EOF)*/

These two loops have nothing in common. Change the while loop to look like the for loop.

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

you can use system("cls") but that will clear the entire screen, not just a part of it. Beware that this is an OS command though

It's also not portable and is not recommended. If you use it on Linux, which a lot of people here use, it doesn't work. In general, programs should not call the operating system to execute commands unless there is an exceptionally good reason, and system("cls") and system("pause") are not good reasons.

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

... otherwise declare void main()

main() is an int function and officially cannot be be declared as void. In fact, some compilers flag a warning if void is used. Forget what M$ claims in their help. They are wrong. :confused:

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

Unfortunately it doesn't. C & C++ are ignorant of the screen. They only know that output goes somewhere without really knowing what's on the other side.