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

looks fine up to main. But because of the lack of code tags, I can't tell what's going on after it. Try reading this for your next post, or the words on the input box background that you ignored when you typed over them.

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

could anyone tell me what are the max values that can be entered in turbo c++ gotoxy function.....
the help says that (35,25) is the bottom right position in the window but i can enter text even upto x-coordinate 50..
what i want to do is enter text at y- coordinates greater than 25....
is this possible ???
plese help.... i have a project to submit within a week and this is a mojor roadblock.... :S

Try it... Do larger numbers work? If so, fine. If not, you'll know that, too.

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

Yes it is... You have to know the value of PI and then divde it by 17 then add 4 then goto 'AREA 51' and get the secret link to click to retrieve it!

I know the value of PI -- 6.98 for a fruit PI, 7.98 for cream PI...

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

Huh? Hosed? That means deleted.

No, hosed means screwed up, not deleted.

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

You posted there.

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

So Clinton, what was the purpose of your post? How does it help sneha_venky with figuring out a project to program?

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

At the end of your code, you have

cout<<"\nPlease enter +,-,*, or / and then two numbers,\nsepperated by spaces, that you wish to\nadd,subtract,multiply,or divide.\n\nType e and press enter to exit.";
        cin>>choice;
        if (choice != 'e')
        {
            calc(choice);
        }
}

This will only run the calculator once. Change the if to a while (with a couple other obvious changes) and you should be good.

Also, see this about your void main()

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

OK, found the answer in another thread...

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

Yeah. Popups bad. Me no like. Gross!

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

It's a secret message you're to authorized to read... :icon_twisted:

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

Dani, could we have a control panel option to shut off the mouseover display please? The display really gets in the way, covering multiple posts so we can't see what other posts are available. I for one find it extremely annoying.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
105(decimal) = 01101001(binary)

for example, i want to skip first 3 bits of binary and get the number to the right and assign it to an integer:

01001(binary) = 9 (decimal)

could you plz give a little code sample?

thanx.

Set a mask to clear the first 3 bits:

int mask = 0x1F;    // binary 00011111
newint = oldint & mask;
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Actually, I don't understand it, either. The shifting and adding 64 makes no sense.

Since a deck has 52 cards, the loop is going through all the possible cards of the deck (0-51). Then (i / 13) gives you 0-4, representing the suit of the given card. (i % 13) gives the value or rank of the card (0-12). Therefore, if i is 5 you get the 6 of Hearts.

If you want to shuffle the deck, you can then yse the random generator to move cards to different random positions.

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

I prefer having complete control, over having software make decisions I don't want it to make. I always get mad at editors that do things the way they want it done
, instead of the way I want it done.

er... i wonder which code editor you're using... cuz, AFAIK they don't think for themselves...

I agree. My editor does exactly what I tell it to do. Is your editor Word? If so, that's not an editor... :icon_rolleyes:

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

This notification thing is killing me.

Let me kow when the funeral is.... :icon_twisted:

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

Or add a progress bar or textbox to the modal form to display the progress. As an added safety, disable any 'dangerous' buttons while the command is being executed.

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

Or use an older compiler, like Turbo 1.01 or Turbo 2.01.

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

Looks like someone still hasn't read the Rules yet. And this is also very helpful.

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

Using scanf is required in the current course I'm taking.

Did your instructor mention that
1) scanf("%s",strval); will only read up to whitespace, so if you entered John Doe all that was read is John -- and Doe is left in the buffer for the next scanf() ?

2) scanf("%d", intval); leave junk in the buffer for the next scanf() , so the following read may fail? Especially if you are reading a character string next?

Here's the beginning of a series on scanf() and why it should be avoided. I understand you can't avoid it in this case, but at least you will know what the pitfalls are so you can (maybe) program around them.

I'd be interested in what your instructor has to say about this series, if you show it to him/her.

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

fgets() is a nice function to do that. But you don't make any checks for extra characters left in the buffer if the input is longer that the array to hold. Like "Supercalifragilisticexpialidocious" It would have left five extra characters plus the newline behind. By the time you make all the proper checks to avoid that, and discard those extra characters, it is as long to write it as the reads(). That's why I chose getchar() inside a loop with checks.

It's actually not that hard. Minor modification to Ancient Dragon's code fixes your concern:

fgets(name, sizeof(name), stdin);
// remove the trailing '\n' that fgets() might put in the buffer
if( name[strlen(name)-1] == '\n')
{
    name[strlen(name)-1] = 0;
}
[b]else
{
    while (getchar() != '\n');
}[/b]
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hey there, 1o0oBhP ....... err, that was quite a mouthful (err, keyboardful) spelling out your name :)

That's why I cut'n'paste :icon_smile:

In any case, we like to make it a general policy not to create new forums until we see a need. The phrase "build it and they will come" doesn't seem to work when creating new forums. Therefore, if we see a significant number (15+) of MatLab threads being posted in the Computer Science forum or the Other Languages forum, then I'll go ahead and rally those threads together into aq new MatLab forum.

I've notice quite a few MATLAB questions in Legacy and Other Languages. And for a period of time, only Matlab questions were asked. It seems to make sense to open a section if we can find a moderator.

However, if members aren't talking about MatLab now...

Oh, but they are.... (I think) :icon_wink:

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

Pointer strings always end with a '\0' character so calling strlen to find the end just slows the whole function down. This is a good pattern to get in the habit of using.

for ( i = 0; s[i] != '\0'; ++i ) {
  /* Do stuff with the character */
}

So what if strlen() adds a few microseconds. That is not a good reason not to use it. Both versions of the loop work as expected so use the one you like best and is easiest for you to understand.

islower exists because this code doesn't always work. Some character sets have holes in the alphabet characters that aren't a part of the alphabet. Your code gives a false positive on those characters and islower wouldn't.

Yes they exist. But the technique used by VatooVatoo works just fine for all the character sets in common use, which is ASCII. Yes, EBCDIC still exists, but it is not in common use outside of IBM mainframes -- generally not a computer people learn on.

This is even worse with the holey character sets because subtracting 32 would give you a completely different character that might or might not even be a letter. That's why toupper exists.

Again, only EBCDIC would be a problem. Therefore, all three of these suggestions are good techniques to know, but not because they are bad. They are just alternatives.

The worst part is that your function doesn't append '\0' to the destination string so it's …

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

And when I replace the double variables with integer ones it suddenly beggins to work(there is a huge bug with that,but it works) ,maybe somebody can explain?)

The only way this can happen is the file contains integers, not doubles.

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

What wee is saying in his own way is you must do something before we can help you. All we can do with the info you've given is write it for you.

Please read this as well as The Forum Rules

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

My advice is to tell us what the errors are. the more you explain the problem, the better (and faster) we can help you solve it.

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

Create your post in an editor. When done, copy and paste the entire post into the edit box. Hit PREVIEW and fine tune your post. Simple.

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

Yes, you can get help here.

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

how do i build a graphical user interface in visual c++

Since you never mentioned OS I'd go for OpenGL.

How many OS's does Visual C++ work under? Another DUH moment... :icon_wink:

iamthwee commented: Huh? I was asking what OS he wanted to write the GUI for. Oh dear. -2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Sorry WaltP, but this time you missed by miles. Before jbennet post there was another post which got delete as it was spam. I flaged that post as spam.
Now WaltP you own him appology ;)

No I don't. If he'd learn to reference (quote) the post he's commenting on, his posts would make sense. Since he doesn't, it just looks like a wayward useless piece of advice. Why should I have to search for the post he's commenting on?

And to top it off, what's the sense in replying to a spam post? They never see your comment. :icon_rolleyes: IOW, post when necessary, not just because you can.

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

i'm suppose to key in 2 value , but need to display error whenever character is entered. thus end the program. can i still able to string all of them?

You've been given 3 examples. Maybe you should try to use one of them.

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

And using %d, the sscanf does some strange things. %d must read int, but when we read into int and then print that number, it prints correctly even numbers which are greater than 65536. This should mean that it would write into memory larger than int allows, which is overflow. The easiest solution is to always use long int, and %ld, when reading with sscanf, but this would not much help when the aim is to enter very big numbers.

This is only true if you are using
1) 486 or earlier computer
2) an older 16bit compiler

If neither, int s have been 32 bits ever since the 32 bit machines/compliers have been around.

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

Dont spam

Thank you for that brilliant post. It was very helpful... :icon_rolleyes:


especially considering your signature :icon_wink:

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

It isn't, at all, just the opposite. We rely upon members such as yourself reporting bad posts and spam to help us keep on top of the problem.

I am discussing this with Dani to see if anything can be done...

However. It should be noted that the drive behind the rep change has always been to get back to the rep bar being an instant and obvious gauge of the ability of the poster to answer support questions. Not perfect, by any means, but the best we can come up with.

I don't feel that repping the reporting of a bad post should be counted. As has been mentioned, it should reflect the helpfulness to other in answering questions, not policing the board.

Just my 2 dracmas

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

Actually, its true. Turbo C++ is an old DOS IDE and it doesnt run on XP without some major tweaking

Then your XP is broke. Works fine on mine with no tweaking -- and I have version 1.0 loaded.

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

What would be used to decide that there's code? The only script I've seen is for C/C++ and looks for {, which means if your post includes a brace but no code, you have to put code tags somewhere anyway...

I think that's the main one for C/C++, although I do believe there are one or two other triggers. I don't think it matters too much though, it's very rare for someone to use {} in ordinary text, and by that time they're usually experienced enough to know how to use code tags. I would think a disable script or some option in the user CP for experienced members would suffice.

Au contraire. I've used braces in a post quite often when describing code formatting. Although I do like the CP idea.

And what criterion would be used for other languages?

Well at the moment it would mainly be useful in the C/C++ boards, because they're the ones that get the most number of threads/day by far, and thus have the biggest problem with untagged code...

But all languages have the problem. I dislike the concept of "ignore the others, they don't matter". Each language has moderators adding CODE tags (I hope :icon_wink:)

Or, for new members posting on a programming board, the first few posts get a short guideline spiel that mentions readability, proper question, enough information, and code tags.

What if they ignore it? They seem to ignore all the other hints we put in place...

We ignore them.... …

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

about the fflush, I know its wrong but I guess since I'm a beginner it's easier to just tell me to use that while learning the basics since portability will be an issue later...

And after you've learned to use it, and after time forget that it's wrong, what are you going to tell your boss when the program doesn't work with their compiler when you get a job? Tell him "it always worked before!"?

... but for now everyone is using the same compiler so all is well and you can add that to the article which lead me to this site, "What Are They Teaching C Programmers These Days?"

As my mom always said, "if all your friends jumped off the Empire State Building, would you do it too?"

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

A word of advise...
Use a post title that asks a real question and "texting English" is frowned upon here.

Almost. Don't ask the question in the title, tell us what the question is going to be about, like "Compiler Error". Read this

I am not familiar with your compiler, but it SOUNDS old. You need a modern compiler to compile c++. The error looks like some kind of incompatibility due to age or format.

No true. That's like saying you need a 2007 Corvette to drive n the road so get rid of the 1968 Mustang.

Between your bad title and scant information, it's hard for anyone to help you if they wanted to.

Again, true. We need accurate information, like the exact error message and the code in that part of the program.

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

Below is my code: Why does it not print anything out? As you can see in my previous posts, i was using a wile loop, howver, my instructor said i can't use it.

Comments point out problems:

#include<iostream>
#include <string>
#include<fstream>


using namespace std;



int main()
{
	
	ifstream inFile;
	ofstream outFile;

	inFile.open ("random.dat");
	outFile.open ("randout");

	int numbers[91]={0};
    int counter=0;
    int num=0;
    
    inFile>>num;
    
    {
    bool found = false;
    for(int i=0;i<=counter;i++)  // counter is 0, so i is always <= counter
    {
            if(numbers[i]==num)
            {
               found=true;
             }
    }

    //// after you get here
    //// 1) you never saver any index so you don't know which
    ////      numbers repeat
    //// 2) counter still has no value
    if(!found)
    {
		cout<<"These are the non-repeating #"<<endl;
        numbers[counter++]=num;
    } 
	inFile>>num;
        //// You just read a number, and exit the program

     }    
    return 0;

}

You need to break you program into steps.
1) Read all the data
2) Next, look for duplicates and remember them by setting a flag in another array. Use 2 nested loops.
3) Loop through the flag array for any non-set values, those are the non-repeating values

So I see 4 loops necessary

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

What would be used to decide that there's code? The only script I've seen is for C/C++ and looks for {, which means if your post includes a brace but no code, you have to put code tags somewhere anyway... And what criterion would be used for other languages?

I guess what I would like to see, if a script is used like the one I described, is that it runs for a certain number of posts with code, then shuts itself off. Say after 4 times a member posts code the script goes away.

Or, for new members posting on a programming board, the first few posts get a short guideline spiel that mentions readability, proper question, enough information, and code tags.

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

I am working off the code that the professor provided, but for some reason I cannot get it to work. It is giving me errors.

---

the error I recieve are the following:

1>source.cpp(5) : error C2653: 'xy_coordinate' : is not a class or namespace name
1>source.cpp(7) : error C2065: 'x' : undeclared identifier
1>source.cpp(7) : error C2065: 'y' : undeclared identifier
1>source.cpp(9) : error C2653: 'xy_coordinate' : is not a class or namespace name
...

Sorry, but this thread had me shaking my head in amazement!

Dumb help #1:

i think something is wrong in your code. Have you debugged it.

Duh, you think something's wrong? What's your first clue?
And how do you debug something that doesn't even compile? :icon_rolleyes:

Dumb help #2:

Have you compiled the source?

Where do you think the errors come from? :icon_rolleyes:


ok, I placed this in the source file:

#include "xy_coordinate.h"

now i get 6 errors:

1>source.cpp(8) : error C2084: function 'void xy_coordinate::input(void)' already has a body
...
1>xy_coordinate.h(8) : see previous definition of 'input'

1>source.cpp(12) : error C2084: function 'void xy_coordinate::print(void)' already has a body

1> xy_coordinate.h(9) : see previous definition of 'print'

1>source.cpp(15) : error C2084: function 'double xy_coordinate::radius(void)' already has a body
...

Dumb help #3:

Is your header file linking to main prog?

With the change in errors, isn't it obvious the header is linking in? It's just linking wrong.
Note 'void xy_coordinate::input(void)' already …

iamthwee commented: b i n g o! +12
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

And Opera is now free, and updated. May be worth another try.

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

It's because in the code

void someStrFunc(const char *str){
 
    char *tmp;
    strcpy(tmp,str);
 
    return;
}

tmp is just a pointer and has no space assigned to it. Therefore you are copying the string into unknown memory outside of your program space.


The same thing is happening with

int main(){
    char str[] = "I Want To Know";
    char *tmp;
    strcpy(tmp,str);
    return 0;
}

but the unknown memory is part of your program space. You're still overwriting memory.

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

You can also use system("PAUSE"),

NO!!! Here's why

DevC++ puts this in for you automatically,

Only if you don't correct the template, which IMAO everyone should do.

i'm not sure about linux at all since i don't need to use it on Linux :)

And here's one major reason why you don't use it!

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

I don't see any need to separate the lines into words, just look at the characters after you read the line and if you see a space just ignore it.

Easiest way I can think of is to set up a 256 integer array and for each character increment the location using the character as a subscript. Then after reading the file, look at the array locations for 'aeiouAEIOU' and add them up.

Alternatively, since the only non-alphabetic chars are SPACE and '\n', set up a switch statement that tests
1) SPACE and '\n', and ignore them
2) All vowels, and add to a vowel counter
3) default, add to a consonant counter.

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

longs are numbers
"" is a string constant
You can't mix the two.

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

Why am I receiving the following errors:
'seenBefore' : function does not take 1 arguments

bool seenBefore(int, [B]int *[/B]);

syntax error : missing ';' before '}'

Depends on where the error is. This is why we ask you to post the exact error message, in full!

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

What's Ponzi?

Ever hear of google? :icon_rolleyes:

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

Aye, he kept himself in ice for a week or something, he did it the same way blane did his box trick - switching with people.

What? Please explain what you're talking about. What was the effect and what do you think happened?

Please quote what you are commenting on... It helps understanding.

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

Well, the opposite of PRO is CON. So opposite of PROgress is ...

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

I wonder if anyone's tried a network-based Ponzi scheme yet?

I'm involved in one right now. It's called the US Social Security System. Look at how it's set up and compare it with Ponzi... Scary!