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

I use it every time and it works. I also tried the alternate spelling "&&" and still the comparisons are ignored.

In the list here:
http://www.cppreference.com/wiki/operator_precedence
both && and "and" are recognized as valid.

If you wish your code to be understood, you should use the syntax that the rest of the industry uses. Though and is acceptable in that list, && is the accepted way. In fact I've never seen and used until now, which is why I figured you had compile errors.

For standards experts: Are all those "extra" operator designations actually in the standard? If so, C++ seems to be looking more FORTran-like today.

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

TCHAR
As for the other things, my psychic powers are limited today. Must be sunspots.

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

You need to keep track of the index yourself. Adter you load A[3] you need to remember that 4 is the next index:

A[idx] = num;
idx++;   // point at next A
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I am running into problem on getting this program done. Its suppose to quiz you on your 2 powers ie(2^2 = 4, 2^22 = 2m, 2^46 = 32t) I've programmed in python for a couple years but a lot of the tricks python lets us have C++ doesn't or I don't know how use them. As far as I've checked C++ doesn't have an append to array.

1) Don't use getch() , it's not standard. Use getline() 2) Append to array? Please be specific. Exactly what are you asking for? Depending, this could be yes or no.

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

Is and approved in C/C++ comparisons?

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

And what's with the mega-indenting? What are you going to do when you have 4 nested loops with IF statements?

4 characters is enough, not 4 tabs:

void countVowels(string a,int& aCont, ,int& eCont,int& iCont, int& oCont, int& uCont)
{
    int nonVowl=0;
    string.str(a)

    for(i=0;i<=string.length();i++)
    {
        switch(string.at(i))
          case 'a':
            aCont++;
            break;
          case 'e':
            eCont++;
            break;
          case 'i': 
            iCont++;
            break;
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I take it you didn't understand what was mentioned in "Member Rules" and the sticky post above "Read Me: Read This Before Posting"

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

From no Code tags to Code tags every 3 lines. :icon_rolleyes: C'mon, put CODE tags around your code. Don't add them just to add them. Don't add them around questions. Only the code -- all of it. Once -- unless you have two distinct pieces of code (two files, two functions that aren't connected)

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

what are the code tags ? i will put them on there if i knew how an error comes up when i do it. arent they just codes for people too type in so when someone to help people they use the code tags? r am i wrong?
just let me know cuz this site is pimp it helps me out alot

Read your PM.

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

Does your system/compiler actually handle 64 bit values?

The 'easiest' way to handle this is to create a union using your double and a byte array. Then output the binary from the bytes.

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

I'll give you the benefit of time this time. You received an infraction warning about CODE tags 7 minutes before posting this. Last warning.

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

And why do you refuse to give us any important information -- like what was the answer you wanted, what was the answer you got, where in the 200 lines of code you think the error is?

Get with it -- we can't read you screen. You need to give us the information that explains the problem, not just "there's a problem somewhere - what is it?"

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

Add a portion of your code in your post -- the part that's giving you trouble -- with CODE Tags (don't ask, they're explained everywhere).

And a complete explanation of the problem code helps.

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

I have one error now..... What does this mean?
: error C2064: term does not evaluate to a function taking 3 arguments

Something in your code is specified as a function with 3 arguments, but isn't a function with 3 arguments.

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

:icon_razz: back....

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

Good. Cuz the answer would've been "Because you wrote it wrong"

Without details, and our lack of psychic ability, what else could we say?

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

If you type in 0 and 0, what are the value of a&b at the end of the while loop? That should help you figure out the two numbers to enter.

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

in C/C++ the square root of a number can be calculated using the pow() using 0.5 as the second parameter.

Isn't sqrt() available?

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

Brief fix! For something posted 6 years ago? Not brief enough...

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

A constant int (i.e. 1) is not an address. It's the value 1. You seem to misunderstand what an address is. Maybe a google search can clear up some details.

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

hello!
just started out here...
i need help with this program
i need to generate a 3*3 matrix having unique numbers in the range
1-9. I did this program using srand but i'm unable to get the correct output...i couldn't figure out the error...could someone plz help me??
here the program

Why is it new people think we're psychic and know what the error you're having is? Don't you think knowing the problem would help with a solution?

All I can assume is you aren't checking to see if a number has already been randomly chosen and loading the same number twice.

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

Now you're in the realm of "what the heck are you trying to do" type of question. Just loading a number into a pointer does not make it an address.
You load the pointer with an address, not an integer.
Explain what you are trying to accomplish, with enough detail for us to understand. You'll probably need to post some example code, too.

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

Yes. That's one of the main reasons for having pointers.

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

Hi All,
When I try to compile the code below, I get error message " error: ‘MAX_IMG_HEIGHT’ undeclared here (not in a function)".

Where is MAX_IMG_HEIGHT defined? What's its value?

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

Are you reading a 1) string or a 2) array of characters?
Did your instructor cover either of these?
Whichever one you are using, do you have any idea how to tell if the word Store is in it?
If your instructor and/or book covers them, now is the time to read the notes/book to understand them and the functions involved.

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

Sorry, you were wrong. The other loop with getline() was the proper start. You just have to think about what you are trying to accomplish.

Write down on paper what you are trying to do. Step by step. Detail by detail. Read a line. What do you do with it?

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

I did not ask what if should do, I ask what it does do. In detail. Answer the questions I asked. There were 3 of them.

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

Stop using scanf() and fscanf() . They won't work for you because of your data, and you don't know how to use them -- which is a good thing, actually.

Please explain this loop:

while (!file.eof() )
{
	string line;
	getline(file, line);
        cout << line;

What does it do? What causes it to stop? How does it handle the Store # lines?

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

Either make choice a single character and acquire it by cin.get(choice); (you will need a cin.ignore() after to mop up the '\n'
or use if(strcmp(choice,"Y") ==0) instead of your (choice == "Y") EDIT: D'OH WaltP beat me to it

Or if(choice == 'Y') with choice as a single character.

Wonder why we always have to edit a post to acknowledge being beaten... :-/

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

cout<<"Would you like to preview your output file? (Y/N)"<<endl;
This is the line I am talking about, sorry for misquoting.
But yea I tried inputing 'Y', I will try 'y' but I dont know it it will work

Wait a minute....

You've defined char choice[2]; you're inputting cin>>choice; So what is in choice at this point? Both bytes?
And is if (choice == "Y") the proper comparison -- with Y as a string?

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

hey everyone, I got a weird error when I run my program. I compile and link and run the program through the terminal in Ubuntu. I have to compile or linking errors, and the program run's fine, except when the program asks:

"Would you like to see a display of the output (Y/N):"

I don't see this message anywhere in the code...

Regardless, the only response that seems to work will be Y. y will not work.

cout<<"Would you like to preview your output file? (Y/N)"<<endl;
cin>>choice;
if (choice == "Y")  // only an upper case Y can be entered
{
  cout<<"Generating preview of output....."<<endl<<endl;
}//end if
else
{ cout<<"Very well...MOVING TO NEXT PROCESS"<<endl;}
};//end print_to_screen
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

thelamb gave you just enough for you to actually think about the change and do it properly. He did not give you a total solution...

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

Assuming you wrote Standard C++ it should work with only minor changes. If you didn't, you'll have to find another way of fixing the error (change in function, or even concept).

Start by compiling and fixing any errors that pop up.

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

Where do you calculate both roots? I only see one calculated.

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

ok code is fixed... thinking that i need to use a boolean to convert to lowest terms ... getting lost in the how to take regular math thought to you programming language .... everything aside from the math is working now with no errors ... was thinking something along the lines of using something like this ... am I on the right track here...

for ( int i = 3; i <= num; i++)
{
for (int j = 2; j <= num; j++)
{
if ( i!=j && i % j == 0)

No.

More along the lines of

get lowest of num & den in loopval
set i to 2
while i <= loopval/2 
    if num%i = 0 and den%i = 0 then
        num = num /i
        den = den /i
        i = i+1

with soem thought on the loop to get it correct.... :icon_wink:

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

that worked but now I am getting a whole slew of new errors when I try to compile the same code on my home ubuntu machine

here are the new compiler errors:

assign6.cpp: In member function ‘char cAccount::get_accountName(char (&)[15])’:
assign6.cpp:24: error: ‘strcpy’ was not declared in this scope

So where is strcpy() defined?

assign6.cpp: In member function ‘void cAccountList::print_to_screen()’:
assign6.cpp:104: error: ‘strcmp’ was not declared in this scope

So where is strcmp() defined?

assign6.cpp: In member function ‘bool cAccountList::search()’:
assign6.cpp:148: error: ‘strcmp’ was not declared in this scope

So where is strcmp() defined?

Check your notes...

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

Please forgive me...I'm still new posting anything in these forums but...code tags? I'm sorry. That probably seems stupid of me to not know what that means. Like I said, I'm new to posting in these forums and as far as programming goes, I'm still pretty new to that too. I'm only in my second computer science class right now. Thanks.

CODE TAGS
read any of the requested information posted all over this site about CODE tags, like
1) in the Rules you were asked to read when you registered
2) in the text at the top of this forum
3) in the announcement at the top of this forum titled Please use BB Code and Inlinecode tags
4) in the sticky post above titled Read Me: Read This Before Posting
5) any place CODE tags were used, even in responses to your posts
6) Even on the background of the box you actually typed your message in!

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

Start month at 1 (January)
If your day > #days-in-January
Subtract #days-in-January from your day, add one to month.
If your day > #days-in-February
Subtract #days-in-February from your day, add one to month.
etc.
The first time day <= #days-in-'month', you have your answer.

Set up a loop and an array to do this.

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

this is my daughters homework she asked me to help and now im stuck she has worked it out and is making me look stupid need to get my selfrespect back even if i have to cheat(i used my brain and im asking you) the code is as follows but i cannot get it to work

IMO, you'll get more respect from her (which is more important than your own) by admitting she's better and having her teach you. It'll do wonders for her self esteem, which is sadly lacking in people now-a-days. And you'll feel better knowing you gave her a great ego boost.

By the way, no one can make you feel stupid. Only you can do that.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
int getAvg(school student, total)
{
    ...
}

What type of variable is student ?
What type of variable is total ?

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

Tell us how you would add two matrices on paper.

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

So declare total . What type of variable is it?

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

Yes. But the '\0' in 7 is the end of the string so the last few characters are essentially invisible.

and you do not want to rely on someone typing less than 12 characters.

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

The problem here is that although I manage to rename the file name from "unsaved.txt" to whatever the user enters, the global char* variable (fileName) won't change and remain "unsaved.txt" so the next time I try to write something new into this file it will still create a new "unsaved.txt".

You cannot change the contents of a constant string, which I assume is your problem. If you have: char *fname = "unsaved.txt"; it's a string constant and cannot be modified.

On the other hand, if you have char fname[] = "unsaved.txt"; you can change the name. But if you change it to "theRealFileName.txt" you have another problem. You just moved 20 characters into a string defined as 12 characters so you overwrote unknown memory -- a very bad thing.

To fix that, define the string as char fname[100] = "unsaved.txt"; and you'll have 99 characters to play with.

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

The only way for us to understand your problem is for you to post your code.

I think a better description of the problem would help -- not the code...

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

Write a VB system that connects to a genetic machine that makes clones whose sole purpose it to use your database.

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

assign5.cpp:83: error: too many arguments to function âvoid Sort(cStudent (&)[30], int)â

Well, the function Sort has more parameters in the call than the function is designed to take.

Hope that helps...

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

I don't understand. First you say

For example:
I have the str1 = "Jhon" and str2 = "Lucas"

Then you say

but if my string was like that: "35:Jhon\135:Lucas"

So which is it?

The escape does not works well because the 35.

So what's wrong with the 35?

What I do?

Depends on what the problem is.

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

My initial reaction is it needs whitespace.
1) Indent 3-4 spaces, not 1
2) More spaces on a line for (int j = 0; j < dim2; j++) c.mat[i][j] += this->mat[i][k] * x.mat[k][j]; 3) Blank lines between logical sections

Makes the program more readable.

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

When they pass in the list address to delete, if it hasn't been initialized, don't delete it. Return an error code.