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

A local variable (str3) is deleted once the function ends.

First, loop through the to string to find the \0.
Second, now loop through from copying each character to to.
Return to.

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

Sure, I can. It's simple. And fast to do. Why?

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

Try posting your code readably and someone might be able to follow it.

Indenting is a good thing, but indenting 8 characters is usually overkill, as your code shows.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
int a[10]={3,45,6,78,89,334,4,77,54,60};
int *p=a;

what will *p++ do ?

as ++ has more priority than * therefore ++ will be executed fisrt ?
but its postincrement so it will happen after change of line or statement.

so will it increment the pointer or increment the value hold by pointer ?

*++p will increment the pointer and then derefrence it !! right ?
*(p++) will do the same ?
++(*p) will increment value !!

A quick test program will tell you exactly what each of these do.

now can i achieve increment in both value and pointer in one line ?

For readability, why would you want to? The more you combine tasks the more confusing the code becomes.

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

I'd say there's probably something wrong with the rh.item matrix. Or switching the indecies is not the proper solution for your printing error.

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

Please look at the code you're posting. Can you actually read it?

Please see this, and maybe we can read it, too.

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

Copy the .h into the directory with the code.

Is this really that hard to figure out on your own?

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

"../test.h"

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

To move, you need another matrix. board is for the current state, newboard is for the next generation. Once you fill newboard copy it into board.

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

If you are inputting into an integer variable, you cannot test for characters because they can't be entered into an integer.

If you input into a string you can then test if the values are digits or not.

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

You don't need vectors.
To shuffle,

// get two random numbers: r1 and r2
temp = deck[r1];
deck[r1]=deck[r2];
deck[r2]=temp;

Repeat this until you like the randomness.

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

Look for an initialization file (maybe db.ini) when the program starts. If the file does not exist, accept the connections string and any other values you need, write the data to the file.

On each subsequent program starts, read the file to retrieve the values.

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

OK, done. Now what?

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

I suppose that's a good start. I'm assuming that "carefully design the interface for this class and include functions that appear to be useful for operating on points" does not mean defining a class in five minutes but a well thought-out design. Only you know the instructor and what he's likely to want.

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

Neither are we since you didn't explain your problem.

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

How about

Dim I As Integer, MyCharacters As String
MyCharacters = "ThisWord"
For I = 1 To len(MyCharacters)
  MsgBox mid$(MyCharacters I1)
Next I

It's simple. No redimming or ubounding.

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

What is a point?
What are it's parameters?
What can you do with a point?
Where can they exist?

Basically, you need to create a class that can fully(?) defines what a point is, and decide what a point can be used for and create functions that can make the point class useful -- like making lines, planes, etc.

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

Set up a 52 int array called deck. Load each value with it's index: for (i=0; i<52; i++) deck[i]=i; Now do what iamthwee suggested. This becomes your shuffled deck.

Each entry in deck can be converted into a number/suit pair with / and %. Then use your suitname and numbername arrays for output.

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

floatval= (int) floatval;

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

Because --
1) when you are outputting data with printf() you pass the value into the function.
2) when you are inputting values with scanf() you pass the address of the variable so the value can be passed back.

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

i have a piece of an unfinished program.
try to run it...

No. If you post readable code, we can follow it. Please format your code cleanly and consistently. See this.

if you go straight to option 3 and input values, how do i output these values in option 4 ?
i tried outputting my declared variables
it wont work ? why is this ?

By not declaring them only during option 3. Once option 3 is done, the variables are destroyed. Define them at the beginning of main() .

i apologize the code is so long

Then just post the relevant section of code. Then, no need to be sorry, and we don't have to search so much. :icon_wink:

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

I am very much a beginner and trying to create a linked list, asking the "user" to input 5 or 6 values. My problem is that I don't know the correct terminology or how to store the user's input so that I can create my pointer to the next value and so on. My understanind of the topic is not great, and I think I'm missing a very easy concept.

Sounds like you need to learn and understand what a linked list is and how it operates. http://en.wikipedia.org/wiki/Linked_listStart here[/url].

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

how do I go about adding a row to a column in simple code? and then printing out the results.

No comprende...
If you have a 4x4 matrix, you want to add a row to column 3 so all the columns have 4 rows except row 3? Can't be done.

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

I managed to do it until here

So take the next step and do beyond here. Or do you actually have a specific question that we can answer?

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

i is probably greater than DIM_DICT

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

Just found this recipe, thought I'd share it:
http://www.cgl.uwaterloo.ca/~csk/water.html

Nick Evan commented: :) +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Yes.

Keep track of each move. When you generate the next location, add a 'pointer' back to the previous location.

If you know where you came from at each 'node', you can backtrack straight to the beginning. You have your solution.

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

Add cout's at key points in the code to pinpoint where the problem is.

Walt,
I am new at this, cout's in the each section, not all at the beggining?

If you put all the cout's at the beginning, how would that pinpoint there the problem is?

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

I said:

It's your job to tell us [what's wrong] so we know what to look for.

Not just post 245 lines of code and hope we can figure it out...

Salem commented: LOL - it made my eyes bleed +20
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Let's see -- you've read the names and you've read the votes. What do your instructions say to do next?

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

The other essential thing is to NEVER use scanf() to read a string. It's the same as using gets() -- see this series.

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

Your for-loop is wrong ..

void getRaise(double pay[], int size)
{
// should rather be ..
for(int x=0; x <size; ++x)
...

To restate, since it took me a while to figure out exactly what you meant, take out the semi-colon at the end of your loop definition.

mitrmkar, please be a little more explicit next time. Noticing one minor character change can be difficult to spot without pointing out the change.

at the end of int main i usually put:

system("pause");
return 0;

it means you have to press a key before the console closes

Bad suggestion. Why call the operating system to pause a program when a simple cin waits? And pause doesn't exist on all operating systems.

The OP used getch() for that very purpose anyway, also not recommended. Why include a C header and a non-standard function for this simple task? Again, cin does it. :icon_wink:

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

Add cout's at key points in the code to pinpoint where the problem is.

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

guys i have a problem...this function doesn't work for me...look i want this function to check in the 2 arrays pin,pin2 for previous numbers already stored in these arrays but it doesn't work...

Not a clue. Since I can't I run the code nor can I see your screen, I don't have any idea what it's doing wrong. It's your job to tell us so we know what to look for.

also when i find 2 numbers already stores(same pair of numbers) then i want even if it changes the numbers then to recheck over and over until the pair of numbers is new...any ideas???

Put it in a loop. If the 2 numbers are unique, exit the loop.

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

Keep track of each move. When you generate the next location, add a 'pointer' back to the previous location.

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

We don't write code for people. We help you fix your code.

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

The file is a text says "the quick brown fox jumps over the lazy dog", but when I ran the program, it showed some random number than I expected

No, it showed a specific number -- the value of fp which is not and integer displayed as if it is an integer. In other words, a completely useless value to you. What are you expecting?

My goal is to replace a character...

Then you might want to read the file, and display what was read. That's a much more useful test.

It would be great if you give me an example of codes for those functions.

Sure it would. Then you wouldn't have to write it. Sorry, not gonna happen.

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

Are you going to use my code to pass your course?

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

Now we know why you have 3 infractions... :icon_wink:

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

The thing that is giving me trouble is how to structure my array. I don't understand how to set up the array when I am trying to find the values within the array itself.

You put values into the array and look through the array to find values.

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

And? Do you have a question? Or are we supposed to write it for you?

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

no, plagiarism is me handing you part of a text created by someone else.

No, plagiarism is you USING the document as your own. Theft is you giving something you don't own to someone else -- sort of. It's definitely not plagiarism.

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

I think it makes sense, when somebody says "Given an infraction", I interpret it as "Being given an infraction point" - a quantity of how much a user how violated the rules.

It's more that the user has received one of the infractions -- not the points. Getting a Spam Infraction nets you 5 points.

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

Who wrote this piece of dreck? It's utterly disgusting. Try to find code from a different source to learn from.

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

i already started it

Prove it. Just saying you started it does not mean we're going to write it for you.

plz if u can help me i will be very thankful

We will help. But you have to explain what you need help with. Details, specific questions, those we can answer. And code.

Read the Member Rules...

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

Then take the message out of the loop and figure out how to remember that the name wasn't found during the loop...

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

Ok I figures some of it out, but I am still confused about adding a function. I thinks it double avg (int a[]) I know this goes above int main (), but I dont know how to change the rest of the code to call and calculate the verage.

#include <iostream> 
using namespace std; 
 
const int NumScores = 10; 
 
int main () 
{   
    int score[NumScores];  
	int Average;
    for (int i=0; i<NumScores; i++) //loop that inputs arrays data
    { 
        cout <<"Enter score for 10 test:"<< (i+1) <<endl; 
        cin >> score[i]; 
	
    } 
    for (int i=0; i<NumScores; i++) 
    {  
        cout<<"Average for scores:"<<(i+1)<<"is"<<score[i]<<endl; 
		cin>>score[i];
    } 
	int sum = 0;
	for(int i = 0; i<NumScores; i++)
	sum = sum + score[i];
	cout<<"Average:"<<sum/NumScores<<endl;
		

	//Pause
	cin.ignore();
	cin.get();
	return 0;

}

What code actually calculates the average? That's the code that goes into the function. Then where you took the code out, add the call to the function.

Return the average, and output the return value.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
#include <ctime>
time_t t;
     time(&t);
     srand(t);

Or shorten it to simply:

srand(time(NULL));
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

One easy fix is what you came up with. If you want a 10x10 area, make it 12x12 and the active area is 1-10. Keep all the edge values 0.

Also, rather than that list of if statements, you could use

if a(i,j) = '*'
    for i1 = i-1 to i+1
        for j2 = j-1 to j+1
            if a(i1,j2) = '*'
                n=n+1
if n = 3 or 4  
    b(i,j) = '*'  //3 & 4 takes into account the current position
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Yes. See
this