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

But we can tell you did get it! What does that tell you? :icon_twisted:

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

I Can't understand :-/ , Can you please explain in brief.

Sure. Joke.

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

Neither do we. You didn't tell us why you think it's wrong. Did you miss the post titled Read Me: Read This Before Posting?

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

I would also suggest better formatting. See this and pay particular attention to the Indentation section. As it is your code is very difficult to follow.

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

Hey Neik, you should quote the post you're commenting on, not the last one you see. From your comment I thought I screwed up the while statement at first... :icon_lol:

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

We love you too, but we're still not going to write your program for you. Read the recommended info here (rules, posts) and formulate a question we can answer.

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

Fine. If you can't tell us anything, run this version of your program. Maybe then it can give you a clue how to figure out what is happening.

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <iomanip>

using namespace std;
void readAPuzzle(int grid[] [9]);
bool search(int grid[] [9]);
void printGrid(int grid[] [9]);
bool isValid(int grid[] [9]);

int main()
{
	// Read a Sudoku puzzle
	int grid[9] [9];
	
	readAPuzzle(grid);
	
	printGrid(grid);
	
	if (isValid(grid))
    cout << "Is a sudoku puzzle. " << endl;
	
	else 
	cout << "Is not a sudoku puzzle. " << endl;
	
	return 0;
}

//Reads Puzzle into 9x9 array ( modify to read from file )
void readAPuzzle(int grid[] [9])
{
	ifstream in_f;
	
	in_f.open("ma1.dat");
	
	for (int i = 0; i < 9; i++)
	for (int j = 0; j < 9; j++)
	in_f >> grid[i] [j];
}

//Prints out the puzzle read from file (keep)
void printGrid(int grid[] [9])
{
	for (int i = 0; i < 9; i++)
	{
		for (int j = 0; j < 9; j++)
			cout << grid[i] [j] << " ";
		cout << endl;
	}
}
/** Check whether grid[i][j] is valid in the grid */
bool isValid(int grid[] [9])
{
	int i, j;
	bool status;
	status = true;
	
	for (int column = 0; column < 9; column++)
		if (column != j && grid[i] [column] == grid[i] [j])
			status = false;
cout << "1st test: " << status << endl;

	for (int row = 0; row < 9; row++)
		if (row != i && grid[row] …
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

If you look up the format of the if statement, you will find the statement should be

if (license_plate[5] == '9')
{
}
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I said: "I am working on a function to check the validity of a sudoku puzzle. It must check the 9x9 matrix to make sure it follows the rules and is a valid sudoku puzzle."

That's not a question. That is a statement. No one can tell if there is a problem or not.

I figured that the code I posted could be fixed some how. My apologies for not submitting a proper question.

It probably can. But you never mentioned what the problem is.

The problem I have run into is that the program does not know the difference from a valid and invalid puzzle.

That's obvious if you posted here. The problem is you aren't explaining what nor where the problem is. Is it ALL your tests? Just one? We didn't write it. We can't run it. You have to tell us what's wrong.

I have several solved puzzles that I am in inputting, and several that are just random numbers. The isValid() function is supposed to check for this very occurrence. However it is not.

Why not? What's going wrong? What area is it in? Did you output values at key places to figure out where the problem might be?

In other words, read the link, ask a proper question.

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

Well of course...

This is just a function of the program.

My main question is how to check the 9x9 array to determine if it is a valid puzzle.

Oh, I get it. That was not a question in your previous post.

It looks to me like you are already checking the 9x9 array in isValid() so I don't understand exactly what you need help with. Please read the post Read Me: Read This Before Posting so you can ask exactly what you need to know in a way we can help you.

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

Hello all!

New here at daniweb.

I am working on a function to check the validity of a sudoku puzzle. It must check the 9x9 matrix to make sure it follows the rules and is a valid sudoku puzzle.

this is what I have come up with so far:

...

Any ideas?

Maybe finish the program, I suppose... :-/

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

Another thing to consider, what if the user enters 15 characters? All you read are the first 9 and he thinks his password is longer than it is. You should probably accept more characters and give an error if 10 or more are entered.

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

This is not a question for a help forum. This is something you should get from a book, instructor, or tutorial. We can help once you understand the concepts.

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

I don't even know what SF subculture is.

People that go to science fiction conventions. They are a real hoot!!!

I heard that it was something which grew towards the edges of the Petri dish ;)

Many of the DO seem to be experiments going wrong...

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

Search the string for the character. If found, replace the character with '\0'. Ta Daaaa!

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

Each second add 1 to a counter and output that counter.

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

I have a palindrome program.Is there a way to ensure user input terminated in a string by a punctuation mark (e.g. ‘!’, ‘.’, or ‘?’.) in an array?

Get the length or the string, check the last character with the function ispunct()

And how do i get the program to exclude commas?

Copy the input line to a temp line. Use isalpha() to check if the character is a letter and copy only letters. If you want letters and numbers, use alnum() . This will exclude all non-palindrome characters.

Last thing, make sure when you do the copy you convert all the letters to upper or lower case (use toupper() or tolower() ). This is because 'A' != 'a'

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

Some embedded DSP chips have 32-bit chars (and 32-bit everything else) for example.

Wow! They must be for Chinese :)

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

Since this is now a non-issue because it has been answered (and the specified for statement is really stupid to begin with), to stop the further useless posts this thread is closed.

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

I don't see a program, therefore there's nothing to help with.

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

oooook? I haven't heard that in a looooooong time! Are you into the SF sub-culture?

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

I figured putting the rest of the code in there would show my effort that i put into this program, so you could see i wasnt looking for someone to do my homework.

Sure it shows your effort, but there's no indentation that makes the code readable.
Justlikeinenglishifyoudontusespacingcorrectlyyoucanteasilyreadthesentence.

...but it seems whatever string i use to do a .find it returns an error and doesnt seem to work, i used the userChoice to store whatever the user inputed, so i was curious how tempString would work to find search text? thank in advance for the help!

Since we have no idea what you tried, no idea what was in the variables, no clue what the error was, what would you like me to tell you?

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

Maybe not, but it was fun finding the videos! :)

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

I can. But so can your book and Google.

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

Your formatting is still hiding your errors. Pay closer attention to the section on Indentation and you will see a glaring error when you indent properly.

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

i cant seem to figure out how to write the void function void (searchRecords() ) of Search for matching records tried numerous things, what i need it to do is just search for a record and display it to the user how many matches found, thanks in advance for any assistance rendered

As a new member, maybe you can help us out. Is there something we can do when someone becomes a new member so that they will read the rules about posting as requested? What would have enticed you to read them?

Just looking for a little input... Thanks.

Since you read the record into tempString , then tempString.find would work better.

Also read this about while (!inFile.eof()) (feof() is identical to .eof())

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

I'd suggest looking at what time-value is used to designate when posts are read vs. unread and when that time-value is set and reset. If I don't explicitly log off, is the value set at other times regardless of my on-line or even on-site status?

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

If you learn now to format your code you will discover it's easier to find errors and your code will be easier to read. This is very worthwhile when you get to more complex programs. It also helps us understand your code.

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

If you start count at 0, you won't have to subtract 1 at the end of the loop.

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

Hi
It does compile but it doesnt do what i want it to do i want to create a 2d array using the black and grey blocks from the ascii code with each dn value being either grey or black.

Most of us aren't psychic here. You need to tell us:
1) what the program did
2) what you expected
3) where in the program we should look
Don't leave it up to us to read you code and figure out what's wrong. We need details.

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

In your first post you did good -- mentioned what you wanted and what the program actually did. This time you left it up to us to figure out what happens. always tell us
1) what you did,
2) what the program did, and
3) what you expected instead

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

Daniweb time: 12:00PM. Current time: 11:00PM.
My settings: GMT -6 Central with Automatically detect DST. I'll switch it to Always on.

Now set to Always off. Hey! I got the right time! Looks like a bug in the Automatically detect DST setting.

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

Please read the rules as suggested when you registered so you can post an intelligently worded question.

And based on this post you can probably figure out what the answer is... :icon_rolleyes:

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

Hi im trying to take a .dat file with just a list of integers separated by lines. The program has to allow for whether or not the list is an even amount of numbers or not. im a bit stuck


well what i want it to do is store the values of the file into an array and add to the counter. ive been trying different ways of doing this so things like this while loop might not make perfect sense. can you explain how to initializ the rest of the array so it can match the count.

What you wrote above and the code you posted do not match at all. Your description is very lacking because it's simplistic, confusing, and too much info is missing. The code you wrote requires much more complexity that the above description, too.

Start again and state clearly from beginning to end what you are trying to accomplish. Post additional details that might be necessary, like the input file. And what your expected output should be with the posted input as well as what the output currently is.

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

WaltP
1. See the link I posted.

I did. Try one then the other is not a portable solution.

2. How many CLI systems do you know of these days that are in common use by the hoi polloi? Anyone writing secure systems or for something old or unusual won't post here asking how to clear the screen cross-platform.

Lots. With this list of O/S's "you can count on "cls" or "clear" being present on most systems" a invalid statement. Granted, not all the systems listed are in use today, but more than Windows, *nix, and OS/X have been posted here.

And, since I keep getting blasted for being just ever so slightly off when I make a statement like yours, then we all better be more exact. I no longer make a blanket statement that has 'grey areas' if you go back far enough or get specialized enough. Sorry.

Anyway, no matter how you slice it, "you can count on "cls" or "clear" being present on most systems" is simply bad advice.

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

When writing my pseudocode I declare my variables in a module called housekeeping(). We are currently working on reading input from a file or files rather than asking the user directly for input. I am a bit confused how this might work with my pseudocode though. I know how I might write it out but am unsure of the file I am pointing to. In this project I would need to point to the file which contains the player’s number, name, etc.. The print chart is an output file so it would not come from there. Where and how might I include the fictitious input needed for the program to run?

Open input file [I]X[/I].  Read from [I]X[/I]
Open output file [I]Y[/I].  Write to [I]Y[/I]

Basically, that's all you need for terminology.

char columnHead = “PLAYER NUMBER FIRST NAME LAST NAME BATTING AVERAGE”

In the line above would you space twice after player number and 16 spaces after first name because that is how many char spaces are allotted? Or is it just spacing enough between the headings to allow everything to fit and look nicely?

Leave enough space for your field size plus a couple characters between columns.

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

Scroll down to the very bottom of the site and, right above the copyright, it should say "The time now is XXX". Make sure the time it says is the same as your current local time. Otherwise, change your settings accordingly.

Daniweb time: 12:00PM. Current time: 11:00PM.
My settings: GMT -6 Central with Automatically detect DST. I'll switch it to Always on.

I have mine set @ 24 hour :)

Remember WALT,"Database thread tracking" is in effect here and if you dont click MARK ALL READ,your "New posts" wont be updated (All posts you didnt read that were NEW before will still be marked that way)

Always do. And if I didn't read them, they'd still be marked. I'm seeing posts are not marked that were posted after I left the system.

Latest data:
At 4:18PM I shut down my computer with no unread threads
At 10:31 I was back up and entered Daniweb. In Software Programming C and C++ forums:
First thread error: Missed 3 posts timestamped from 6:30 on (5:30 actual)
Second thread error: Missed 1 post timestamped 7:40
Third thread error: Missed 2 posts timestamped from 9:43 on
Forth thread error: Missed 1 post timestamped 9:51

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

There is nothing wrong with using a system program to clear the screen. It is simple and you can count on "cls" or "clear" being present on most systems.

Totally disagree.
#1) Which is it going to be? And how do you write portability with multiple choices like this?
#2) I somewhat doubt most systems have them. Windows may have cls and most *nix I guess have clear, but these are far from being most systems.

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

Please post formatted code so it can be followed and understood. It will help you in the long run.

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

Start a loop
Output the menu
Accept the selection
Based on the selection, do the appropriate task. (Don't forget an exit selection)
End of loop

Did you bother to read the rules, especially the CODE TAG information?

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

Hi, i'm one of those annoying students here to ask questions :)

Not as annoying as most new members. At least you used CODE tags, and have attempted to format your code. Good job!!! For additional formatting suggestions, see this. By the way, don't use both INLINECODE and CODE, just CODE

do i have to use the get function to get the numbers from the user? (although it doesn't ask for it)

Not necessarily. getline() makes more sense to me because of the way the get... functions work. Then convert the input to the value.


Also, about system ("Pause") , see this.

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

Many of those errors are self explanatory. Fix those first.

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

Today it was really bad. It seems I missed all posts from 3:30AM or so to at least 10:00AM, and many through 2:30PM.

And the post times are off. It's 3:05PM and the recent posts are 3:45+ (a DST problem?). My settings seem to be correct.

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

On what above? There is no post above this one! And try reading the RULES as recommended multiple times during your registration here, as well as the post at the top of the forum clearly titled "Read Me: Read This Before Posting". Notice the wording -- before posting.

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

teach me how to format my program befor posting

Here you go

You might also try the post titled Read Me: Read This Before Posting as well as this announcement

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

Turbo C Ver 1 also prints, so it's probably a bug at least through ver 3. Borland 5.5 works as expected.

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

Jeez, talk about spamming a thread :S