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

When you loop through the line you convert only the digits. But if one of the locations is not a digit, not only do you skip it in the source string, but you also skip the same position in the destination array -- leaving uninitialized data in that position.

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

Read the file line by line and when you get to the line you want, stop. Might need an if statement

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

Hi, there, I have written a program here which shows plane to book a seat, and enter flight info(this part works fine)... but having some small problem here I am using gotoxy and it gives me an error, it says that gotoxy undeclared. Could anyone help me with this please, correct the code or tell me how to do it. I am using Dev C++.

In the Dev C++ documentation, what does it say about the gotoxy() function? What ate the parameters? What header is needed?

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

Post the freakin' errors. We can't help you if you keep the errors a secret.

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

really? 2 .cpp files? even for such a short program? Ok now i'm even more confused. Do i need a separate .cpp file for main()? but then again, i'm still not sure what function i'm putting in the header.
ARRGHH! i know this shouldnt be soo complicated but i'm just hitting a wall here

As far as I understood, this seems to be partly about having multiple files in your project, hence two .cpp files plus a header.

Where are you getting this? I said
"You don't need a user defined header file for this program unless you make two .cpp files. "

I did Not NOT *NOT* say "you need to make 2 .cpp files." main() is only and int function. You need to "write a function" that main() calls that returns an integer, another that returns float, etc. Look at my hint#2 and stop being confused by what's written here and read what's in your book when we point out hints.

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

Sorry my English is bad.

Yeah, you sound like a lawyer. They can't talk English either.

The problem im having is:
A.the number generator is repeating the number it generates alot how can it be made more random on every call.

At the beginning of the program you forgot the srand() function.

B.The program is generating alot of matching combinations of words and is not calculating all the possible combination of words.

Example please....

I repeat -- forcefully --

And please format your code. When you need help from others, said others must be able to understand code posted. Formatting aids in said understanding.

I for one am not looking at code that is not formatted. See the link from the last request.

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

Of course.

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

There is an obvious formula for moving from one column to another and one row to another if your matrix is designed as a 1D-array.
Consider this 3x4 matrix: *matrix = {1,2,3,4,5,6,7,8,9,10,11,12} What does this matrix look like in row/col form?
What is the contents of
-- row 1?
-- col 1?
-- cell 2,3

From that info, you can create a formula to determine what number to replace [][] with that can be added to the pointer itself, as in the first loop I posted above.

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

Hi, thank you all for your notes.

I've looked at the sites you've offered but dont seem to be able to make anything with them which suit my requirements.

They don't? What did the link tell you about feof() ?

You also never answered Q#2.

I may not have explained the problem that well, or perhaps C can't do whats needed as i've extensively looked across the net and not managed to find a function which does what i need.

Of course C can do what's needed. It's trivial. It's the programmer that needs to tell C to do it.

If you want help, you need to give proper information, not restate the obvious.
If you are having a problem, focus on the problem, not the end result.

What is the problem? Explain in detail. What happens that's wrong? What did you want to happen instead? Without that, we have no idea what you really need help with.

jonsca commented: "diff" must have been written in Pascal then ;) +2
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

me too :confused:

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

Your if statements

if (type = 1)
if (type = 2)
if (type = 3)

are setting type to the values 1, 2, 3 and each if is executed because of that. Look up the comparison operators again.

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

This might help

#include<stdio.h>

int main()
{
    int ary[10] = {1,3,5,8,12,54,2,77,49,12};
    int *ptr;
    int  i;
    
    
    ptr = ary;  // set the pointer to the address of the array

    for (i=0; i<10; i++)    // add the index to the pointer
    {
        printf("%d ", *(ptr+i));  // ptr remains unchanged
    }
    printf("\n");           


    for (i=0; i<10; i++)    // increment the pointer itself
    {
        printf("%d ", *ptr++);  // ptr is changed
    }
    printf("\n");
    
    return 0;
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

1) Post the EXACT error message. Many time the paraphrased error is missing pertinent -- like line numbers.

2) found the first error -- you forgot to put () around the if comparison. You have them only around the terms, not the entire comparison.

3) No, a string and int are not the same. Just like you can't make pudding out of a rock. Find out where the error is and decide what you are trying to do. Then figure out a way to accomplish that desire.

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

You don't need a user defined header file for this program unless you make two .cpp files.

hint #2- overloaded

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

Nathan's version: fout << v1[i] << "\n"; mrinal.s2008's version: *out_it = *p; Are they similar?
Do both forms work?

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

hello, i have been struggling with this program for a few days now, and have decided to get some feedback.
* * * *
If anyone has any questions on any of my code or program description please let me know. Thanks!

Why would we have questions? I think it's much more important if you have questions. And if so, ask them.

If you posted this because you are having problems, we are not the Psychic Programming Network. You need to tell us what you need.

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

Why would I hate you? You posted code with CODE tags! You are already one of my favorites!

So what does your code do now?
What the the next thing you need it to do?
I'm assuming it compiles.

Remember, we are programmers, not psychics. You need to ask questions, not let us figure out what you need to do next. Then we can guide to in the right direction. After all, it's your program, not ours.

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

Help with what?

You have to ask a question we can answer. All you did is describe the assignment.

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

I am in the chapter about classes. Just read it. We us vb in class its the only compiler that I know about that's why I mentioned it.

well, you're in C++ now, so forget VB. It's completely different.

While I was reading about making headers I think I understand the structure but don't know how to tie it into my program or here to enter the code.

You don't need to make any headers, just use the ones already defined.

But the project asks us to prompt the user to enter a day of the year and display the month and day. For example you would enter 6 and the output would be January 6 or enter 360 and the output would be December 26.

I already got that. But you didn't bother to answer any of my questions.

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

I would recommend
1) in the loop
2) after you input the choice.
3) probably using a switch statement or a series of if statements. Functions would be useful too.

Also, I would recommend not using scanf_s() -- or any of the *_s() functions -- because they are useful in only one single compiler. Once you graduate beyond this compiler you will have to relearn a fair amount.

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

What you're asking help with makes no sense. VB? What's that have to do with C++? And why do you need a header?

Forget everything but your first line -- "I have to write a program with a class that will take the number of the day in a year and display the month and day of that number." That's your problem, the rest seems meaningless.

What do you know? Arrays? Math? Number of days in a month?

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

How can i capture the value of void account::depositFunds() and then be able to use it in the getBalance() function. That's what i think needs to happen, but i don't know how to do it.

What value can void account::depositFunds() have? How can that value be used?

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

I think I should rephrase. The keyword is being input by the user, so I don't think a structure in the code with the keyword and number of times it appears will work since the keyword could be anything. Unless I am misunderstanding, which is completely possible haha

Do you have to count the number of times a keyword is found in the file?
Do you have a list of keywords that you grabbed from the command line?

If so, what's wrong with a structure that you add the keyword to that contains a count you can increment when found in the file?

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

Actually, the continent in the Pacific was Mu.

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

do u mean i hv to put in the table inside a picture box and use the scroll bar outside the picture box???

You have been asked to read the Member Rules multiple times. Read them. You're about to get an infraction for Keep It Clean this time -- 1st paragraph.

Your form is MAXIMIZED -- it's set to fill the screen. You cannot make a form bigger than the screen if it's set to fill it. If the form is set as a WINDOW, you can make it bigger than the screen.

But consider -- is making the form larger than the screen a good idea? Would it be better to have multiple forms? Or maybe TABs?

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

system(program.exe)

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

1) Actually look at the information about CODE tags, don't just guess.
2) Is while(!=feof(definitions)) a valid while statement?
3) Don't use feof() to control a loop. Here's why

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

hi
Im trying to make this code go though every possible string combination at said string length though alpha characters using random number generator to do so.The goal is to make this program tell me how many combinations there are at said circumstances set by user.

Said problem is confusingly described by party of the first part in an attempt to impart wisdom as to salient description of said problem.

Do you mean "I want to figure out all the possible string combinations of a given set of characters?"

Are you in fact having a problem? I see no description of the difficulty you are having, just a task description.

And please format your code. When you need help from others, said others must be able to understand code posted. Formatting aids in said understanding.

NathanOliver commented: very nice +1
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

strcmp(string, argv[x])

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

MSG msg ;
HWND hwnd;
WNDCLASS wc;

to me this syntax looks like msg hwnd and wc(all lower case) are variables is this right?

Yes.

and with the exception of wc would changing the other 2 change anything?

Change what to what?

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

Did you define the deal() function to take parameters?
If so, did you pass parameters on the call deal line?

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

Since this is the earlier first post, I will assume this is the thread you don't need.

Do not post the same question by creating new threads.

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

ok i have a 2d array and i want to trace through it.
The Array is
RDL
DLU
i have an entry point of Row1 Col1 which i think is letter R. On this array R means shift right L is shift left U shift up and D shift Down. I need to write i a function that will trace though the array and print the path and the ending point. Im not sure how to do this but this is what i have. I think it somewhat on the right track. The name of the array is Maze.

if(Maze[StartR][StartC]='U') 
{StartR=StartR+1;
 cout<<StartR<<StartC;}

else if(Maze[StartR][StartC]='D')
{StartR=StartR-1;
cout<<StartR<<StartC;}

else if(Maze[StartR][StartC]='L')
{StartC=StartC+1;
cout<<StartR<<StartC;}

else if(Maze[StartR][StartC]='R')
{StartC=StartC-1;
cout<<StartR<<StartC;}

All your directions are backwards. Down and Right are +1.

Other than that, you are on the right track.

As implied in the other posts,
1) What's the starting point? Are your columns 1,2,3 or 01,2?
2) What designates the ending point? How is it determined?
And to reiterate, be careful about falling off the edges of the maze.

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

My problem lies in the fact that the teacher might try to say that I own more than three stands, so then what happens!?!. I'm thinking that there might be a loop or array that would be a little better.

Since the teacher mentions at least three, this would be a good guess - and an appropriate solution.

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

see I don't quite know what's wrong. whenever i hit the comand button, I get an error saying "argument not optional" and I don;t know what that means, I'm thinking that there must be multiple problems that I cannot see.

Neither do we. If you are really using Visual Basic, in my experience the program stops on the statement that is causing the problem. That might be one of the details you need to give us -- the line in error. And a couple lines above and below in case they might shed some light on the issue too.

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

My apologies and thanks, WaltP.
As I was typing out my problem, I was breaking it down to basic elements and I figured it out on my own. Thank you Walt, for making me think about the problem in the most basic of details. I'll post back with a solution of the program if you would like to see the end result.

You're welcome. I suppose that was your first lesson in 'debugging'.

It's also a better way to program. Even before sitting in front of the computer, break your problem down to it's smallest details on paper, then put it back together as sort-of-code (pseudo-code). Then take that map to the computer and write the code. Programming will go faster with fewer logic problems.

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

Good job. But why is 1000 a special case? And 0?

Here's my solution, in C:

#include <stdio.h>

void outNumber(int num)
{
    int part;

    if (num < 1000)         // Last segment
    {
        printf("%3d", num); // output it and return
        return;
    }    
    part = num % 1000;      
    num /= 1000;
    if (num > 0) outNumber(num);
        
    printf(",%03d", part);
    
    return;
}


int main(int argc, char *argv[])
{
    int num = 23456;    // Default this number
    
    if (argc > 1)       // Allow a number from the command line
        num = atoi(argv[1]);
    
    outNumber(num);     // Call function
    
    return 0;
}

Note there are no special cases.

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

Hello everyone,

Background: I am currently attempting a project for a professor of mine, but I cannot integrate my formula properly into my code. The project calls for a conversion from numbers to words. (I last worked in C++ a year and a half ago, so any words that don't make sense in syntax are placeholders so I understand what I was trying to do when I have a chance to look up the proper functions later) I know how I want to isolate each number, and also how to have it export it. The problem I run into is with my IF statements when I am trying to extract the respective numbers.

Assuming the number I am searching for is 15824.23, I would first take off the .23 and deal with it at the end of the equation, and then turn the 15824 -> _15 824

I would take the 824, extract the 4 through mod then divide by 10 so it would truncate off the 4, mod by 10...rinse and repeat until I got each number. After I finished my first group of 3, I would move onto my next group of 3 until I ran out of numbers to extract basically.

<---code snipped--->

Any suggestions on how to best execute this would be appreciated, again I do not want the work done for me, I simply want some tips on the best ways to go about this.

Thanks,
CSStudent728

EDIT: I realize it is very incomplete …

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

@WaltP - I wasn't trying to imply some sort of disdain for the text-based system but instead was just trying to understand what the OP's intent was. What language were you doing when you used it?

I didn't take anything as disdain. I simply mentioned the text based editors because it's one less thing to 'learn'.

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

Thanks once again 4 the help, but does this code look like it can do the sorting job aswell? (it's just matter of my personal satisfaction) :)
Salut

Why are you asking? Does it work? If not, no. If so, yes.

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

There's so much wrong
1) you input the line into a pointer with no space, overwriting who-knows-what
2) you use feof() to control the loop -- see this
3) formatting, though not disgusting, isn't great.
4) you never count the occurrence of any values, you just add 1 every time you happen to see a number two or more time in succession.

Set up an array to keep track of how many times a single digit is seen.
When you see a digit, increment the corresponding array position.
You can read a character at a time rather than a full line.

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

When you enter 10 characters using gets() you overrun the buffer you are inputting into by at least one character, wiping out data you should not be touching. See this about gets() Create a loop and use getchar() instead. getchar() is designed to input 1 character at a time as you want. Or look up fgets() as mentioned in the link.

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

I1. You could Google "stdio.h". This header file handles many of C's input and output functions.

That's only if you know stdio.h is the header you need. Now that it's been mentioned, go for it.

2. You could try Googling anything to do with C programming except not to include the following in your search: "C" or "programming".

Without "C" you'll get C, C++, Java, Fortran, Cobol, Pascal, Python...
Use the language name in the search.

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

Hey, I'm a student with rudimentry knoledge of VB6 and I've a college project where I have to develop a blackjack game. Unfortuanately I've a problem with the method I call the cards I was wondering if any of you would be able to shed some light on the problem.

You didn't explain the problem. You need to give us details. Don't make us try to understand the code you wrote that you can easily describe, without an explanation of what the trouble is.

Details, please.

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

How about a Hello World program with variations:
Hello Country
Hello Planet
Hello Person
etc.

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

Can someone help me with this code..
I have a function which is InsertNode()
it is use for inserting a new node after the index in the
double link list..

For example I want to add a node of value 6.0 after position 3
This is the code i write..but It seems like wrong...

What seems wrong about it? Is it just a feeling that it's wrong? If so, run it and find out if it is wrong.

If your feeling proves to be correct, then repost and explain what actually happened and what should have happened. Details are necessary.

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

Simple.
Split this line return( fib (num-2) + fib (num-1) ); into
1) compute the value
2) print the value
3) return the value

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

A GUI is not necessary. Long before there was windows, there were editors.

The way to get started is-- Code nothing until you do the following:
Design how you --

  • accept the file name
  • display the file after reading it
  • move through the file when you can only read part of the file at a time
  • use the keyboard to move through the file

The very original editors did not use the screen. For example my favorite older editor, TECO, use the * prompt and input commands:
T- type a line from the cursor position to EOL
L - line move to another line
Ixxx - Insert 'xxx' at the cursor position

This would be a preliminary command list if designing a TECO-like editor.

Further definition would be the modifiers, such as numbers that tell 'how many':
If you cursor is in the middle of a line, 0T will display from the beginning of the line to the cursor. Display the whole line with 0TT
-5T5T - display 10 lines, 5 before, 5 after the cursor.
2L - move to the beginning of the 2nd line following your current position.
etc....

You need to know where you're going before coding. then program bits and pieces. Never program it all at once and try to compile.

I'm not suggesting writing a TECO-like editor, just giving you taste of what you need to think about.

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

A couple things to mention:
1.) This program uses system("PAUSE"); in the main function, if you are not using Windows, you might have to pull it.

Then you shouldn't use it at all. Keep your programs Standard so you don't have problems when you change compilers. See this.

HERE IS THE PROBLEM
I like to use (sizeof("Array To Be Used")/sizeof("Array Type")) to determine my Outer Loop limits.

Why? If you set up the array to be 5, use 5. Just make it a constant at the top of the program so that when you want to change the size you only need to do it in one place.

When I check the Arrays sizes right after I populate the data in main, everything is good. When I pass them to the function, they go down to 1 Element.

So when I am in the function findLowest and I try to get (sizeof(accidents)/sizeof(int)), it returns 1....

I'm wondering what I'm losing when I pass my int array through a function that only see's the array as one element (Although when I force it to show me each element it will, the sizeof( ) just isn't seeing the big picture....does that make sense?

You are losing the fact that there is an array. All the function knows is a pointer was passed in. It has no idea how many locations are associated with the pointer. You need to also pass the size into the function.

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

hi.. friends..
i hav created a new form!! 4 my project but i need a horizontal scroll bar to be attached to it so that i can add more no sections.. to right side of the form!! 15360*11520 is the default size of the form!! i want to increase the size of the form!! how to do it..
plzzzzzzzzzz help!!
Regards
yopirates :)

Change the form.height and form.width values