gusano79 247 Posting Shark

Windows Forms applications can also use the ProgressBar class.

If this is a long-running task, are you performing work in a background thread? Consider the BackgroundWorker class if you haven't already; it works nicely with progress bars and labels.

I don't want to use a true MessageBox as I don't want the user to have to click OK each time

I agree 110%; I'd never use a message box in something that will be seen by actual users. There are always better ways to handle the communication.

gusano79 247 Posting Shark

We could create libraries that could be quizzed by a compiler and return the information about what functions they contain, but that's not how it works in C. I expect that in some programming languages that is how is works.

For example, C#/.NET

gusano79 247 Posting Shark

8 1 0 9 2 7 12 56
This clearly works and is very elegant in its implementation.

Is that the last result? Because it's clearly not sorted...

Ah, I see. It's the first partition, not the end state. Sorry, disregard.

If possible, could you explain me the idea behind writing the partition as mentioned above?

In other words, do you mean "how does partition work?"

gusano79 247 Posting Shark

It's in your post title... see this overload of Math.Round; I think it is what you're looking for.

gusano79 247 Posting Shark

old habits ...

...are like John McClane?

gusano79 247 Posting Shark

Is there a way to have the dowork event (that invoked the progress changed event) interrupt execution until the ProgressChanged event is finished?

I think the short answer is that no, there isn't. And I wouldn't recommend it, either; using a progress reporting feature to do something other than report progress seems like a bad idea.

I recommend (if you haven't already) that you verify in detail exactly which part of the Excel PIA needs to be run in the UI thread and why. If it's not really required, you should be able to do everything in the background task. If it is, I'd want to break the background task up into parts, calling saveLedgers after the end of the first one and before spawning the next.

gusano79 247 Posting Shark

We aren't going to do your homework for you. Try doing it yourself, post what you've written, and we'll be happy to point you in the right direction or answer specific questions.

gusano79 247 Posting Shark

Here's a more complete approach to converting from numbers to words (in English, anyway).

As for the programming task, what assembler are you using? Are you writing something that will run on the same machine you use to code it, or do you have a virtual environment along the lines of 8086tiny?

gusano79 247 Posting Shark

does that mean int ==> passing by reference ..and int& ==> passing by value ???

It's the other way around. & means reference; without means copy (value).

gusano79 247 Posting Shark

Something like this:

if(i.fsize != j.fsize) return i.fsize < j.fsize;
else return /* compare filenames here */

There are other ways to organize the if-chain; this one makes the most sense to me because the higher-precedence comparison appears first.

gusano79 247 Posting Shark

The expression problem is *node(); this works:

//*[@ID=333]//*[@DEEP="Attribute"]

Also note there's no need to check that the attribute exists separately from the value check ([@DEEP and...) .

gusano79 247 Posting Shark

Hm. That "exists" clause seems unnecessary; have you tried updating with a join instead?

Here's the general shape:

UPDATE p
SET p.<fields...>
FROM Packet p
JOIN MSGTO m ON m.MSGTO = p.MSGTO
WHERE <conditions...>

This is what I do with SQL Server; Access might want different syntax, but IIRC it will do this too.

gusano79 247 Posting Shark

Please post the entire program, not fragments. If it seems too long for pasting into a code block, make it an attachment.

gusano79 247 Posting Shark

Can you help me figure out what's wrong with it?

What problem are you having? Does it not compile? ...not run? ...run but not produce the result you expect?

gusano79 247 Posting Shark

From the MSDN page I linked:

In formatting operations, custom date and time format strings can be used either with the ToString method of a date and time instance or with a method that supports composite formatting.

So...

string ddd= DateTime.Now.ToString("yyyy-MM-dd");

Another possibility is this webpage

Those are both correct. The former is "the ToString method", and the latter is "composite formatting".

gusano79 247 Posting Shark

We're trying to help without doing the work for you. Those structs weren't in your original post; how am I supposed to know what you've done?

On to the code...

double exam[size];
double quizzes[size];

Assuming you're getting size from somewhere, should those really be the same? Forget arrays for a moment; you already know exactly how many scores each structure should have.

union S_Eng_sci
struct student

Sure, those work. Now, given student s, you can get "science" scores from s.scores.S_exam and "engineering" score from s.scores.S_quizzes.

All of the basic parts seem to be there; try putting them together in a simple program that just creates a few students and scores. See if you can get the data back out of your structures.

If that works, then...

struct node1

You can use that to construct a singly-linked list, but you'll still need to write code to manage the list.

gusano79 247 Posting Shark

The program should use two distinct structure-types to store the students’ scores: the 1st type used for keeping scores of 4 quizzes while the 2nd type is used to keep the scores of 2 exams.

Where are the structures that keep scores? You're missing them, and they're necessary for everything else, so start there.

adnan121 commented: struct Science { double exam[size]; }; struct Engineering { double quizzes[size]; }; union S_Eng_sci { Science S_exam; Engineering S_quizzes; } +0
gusano79 247 Posting Shark
gusano79 247 Posting Shark

Is this going to change anything to my project (where it will now be found, it's "file name", etc.)?

No changes to the project file name or location. Your classes, though, will automatically belong to the new namespace unless you're specifying namespaces manually (I'm guessing you're not).

gusano79 247 Posting Shark

It looks like Visual Studio has some flexibility, both in UI and custom actions. I haven't used these myself, so I can't help with specifics, but that should get you started.

There are also third-party options like CPack (produces NSIS projects on Windows).

gusano79 247 Posting Shark

What have you written so far? Is there a specific part of the task you're having trouble with?

Hadi.M commented: No actually I have a problem with the entire idea. How do I approach this one? +0
gusano79 247 Posting Shark

You already have a DateTime object; have a look at custom date and time format strings.

gusano79 247 Posting Shark

...but we can help point you in the right direction.

Have you written any code yet? If you have, please post it and try to identify a specific problem you're having.

If not, here's a place to start: You'll need to read that data file into something. What kind of data structures do you think you might want for that?

gusano79 247 Posting Shark

I've always liked The C Book.

gusano79 247 Posting Shark

I'd say it's worth it just for the reduced risk of making unintentional mistakes while generating code.

But if you're working in .NET, the Entity Framework already does most of what you'll want.

gusano79 247 Posting Shark
  • Prevent syntax errors
  • Target multiple .NET languages

Is this an assigment? Detailed explanation left as an exercise for the reader.

gusano79 247 Posting Shark

which didn't look like part of program at all

So the lesson here is software is often more complicated than it seems, especially compiled and optimized software.

RikTelner commented: :(, expected another ending. But it has to do :(. +2
gusano79 247 Posting Shark

Having a control in a separate assembly reach into your main program directly to change values is not good design.

A better approach is to have your custom button class have an event or callback; your program can register something to happen when the button decides it's time. An event will show up in the forms designer, so you can use it like you would any of the built-in events.

gusano79 247 Posting Shark

it could break certification because the checksum may be involved in the process when issue the certification

This is one of the major reasons to have a certificate; to protect against modifications. Though the signature algorithm is usually much more secure than a simple checksum.

after I started application, it said at once, that it's missing a file

The actual error could be something completely different, and probably is. "Missing file" errors are notoriously uninformative, but it's all you can get from some software. It probably means some sort of I/O problem, but I've also seen similar messages when the real failure is security-related.

gusano79 247 Posting Shark

So, there's no way to do anything about user messing up the code using "false" delimiter? I thought someone invented solution for this

If you're talking about delimiter collision, this is a well-known problem that isn't language- or platform-specific. There are various ways you can reduce that risk, and they can be effective if you have some control over user input.

As there's something like mysqli_real_escape_string(); which prevent user to do SQL-injection by doing delimiters.

There are some string-escaping functions in the .NET Framework library, but they're aimed at specific situations like URL encoding. There isn't anything for delimited text files, probably because there is no consistently-used standard for formatting them.

It should be straightforward enough to write your own using one of the solutions I linked above. A common approach for CSV is to quote fields that contain embedded commas, and use two quote characters for embedded quote characters. This can get a little interesting to parse.

gusano79 247 Posting Shark

there are few problems are occur so can any body help me

What problems are you having?

gusano79 247 Posting Shark

So, I assumed that \xFFFD is a character that can't be written by anything but system

No, it's just one that's highly unlikely to appear in anyone's data. As far as I know, nobody has a keyboard that has a key for it, but there are ways to type any Unicode character, so you can't assume it'll never happen.

and further notes says that \xFFFD displays as ?.

Read carefully. That only happens if you write it out using .NET's ASCII encoding scheme.

But you have said that user can't write \xFFFD and reading \xFFFD will result in reading a \x3F (question mark). And then again, you say:

I haven't, and again, the '?' thing is specific to ASCIIEncoder.

Wouldn't that take me to point of start, when I actually try to find proper delimiter?

There's no such thing as a "proper" delimiter. No matter which character you choose, it's possible for it to appear as part the content you're reading. There's no "safe" character that is guaranteed to not be used.

And then this "extra delimiter", the "extra delimiter" now is \xFFFD

What I meant was if someone embeds \xFFFD in their data and you try to read it, you'll need to be able interpret it as a field delimiter and not as content. This is known as delimiter collision.

how many delimiters would I actually need? I have now 4 ,, ;, |, …

gusano79 247 Posting Shark

Loop through the row collection. With each row, look for the value you're trying to find. If you find it, use your iterator (maybe a for loop variable) to identify the row.

If you're having trouble with a specific chunk of code, post it and we'll try to find out where you're going wrong.

gusano79 247 Posting Shark

does StreamReader or any other IO in C# (in Visual Studio) treat \xFFFD as ONE character, or actually 6?

Only one character, but many possible encodings.

When in .NET-land, as opposed to C/C++-land et al., there's only one type of string, which is a sequential collection of UTF-16 encoded characters. That's all you get.

But of course data are typically stored and transmitted as sequences of bytes, so you have various implementations of the Encoding class to convert from bytes to text and back again.

What if user says "I'm gonna troll you so badly let's say \xFFFD", it will be there in data?

If a user manages to get it entered, sure. It'll be there.

But if you're going to delimit text with text, you'll always have the "what if I get a delimiter embedded in content" problem. This has been a fact of life for a long time: C strings can't have embedded zeros because they use it to mark the end of the text.

When \xFFFD is written into file, is it treated as string of 6 characters or actually one character that is unreadable to users?

That depends on which encoding scheme you use. With the .NET I/O library, you always have the option to specify the encoding, although there are some defaults so you don't have to when it's not needed.

Examples:
* ASCIIEncoding will write one byte, but it won't be …

gusano79 247 Posting Shark

Is there a character, that can be written/read by system (C#/.NET), but can't be written by any standard keyboard

Strings in .NET are Unicode, so you have plenty of options. Something like '\xFFFD' ("Replacement Character") might be the closest to what you're looking for. But that seems overkill; you're probably safe using tabs.

Is x00 exploit possible with this?

No. .NET strings can have embedded zeros. You won't be using '\0' to detect the end of the string; the runtime manages finding it for you.

Further reading: Strings (C# Programming Guide)

RikTelner commented: Thanks for the "character". +2
gusano79 247 Posting Shark

Thinking in C++ 2nd Edition

...one of the most useful C++ books I've ever encountered.

gusano79 247 Posting Shark

If you're writing for a DOS-like environment, you'll have to use a few of the interrupt 21h functions. Start there, and if you have trouble, post code and we'll help you improve it.

gusano79 247 Posting Shark
gusano79 247 Posting Shark

if ((s1[i]|32) < (s2[i]|32)) //Set the 6th bit in both, then compare

It's a case insensitive comparison.

Have a look at this ASCII table. The difference between 'A' and 'a' is 32 = 2^6, and uppercase letters all have bit 6 clear. So if you set bit 6, you get the lowercase version either way.

Note that this only works for the ASCII (or equivalent encoding) characters [A-Za-z]... if the strings have other things in them, this comparison will not behave as expected.

gusano79 247 Posting Shark

cant you just convert it to a decimal number (e.g. int), add them up, and then convert back to binary?

This looks like an assignment intended to illustrate a few concepts about stacks and arithmetic algorithms; such a conversion would defeat its purpose. But if it's not (Sami will have to tell us), there are indeed simpler ways to add numbers.

gusano79 247 Posting Shark

the csv file contents the weights of 200 oranges so is it really right to count rows?

Well, it's not wrong... but it's also true that this example is simple enough that you can just read numbers until you're done, so that's not really wrong either.

This exercise isn't really about CSV data, though you could interpret it as a single-column table. I'm talking about rows because that's a concept that will be useful for a wider variety of data.

For example, say there were more bits of information about the oranges... maybe diameter and hue. Then you might have a data file that looks like this:

74.81,6.43,30
70.1,6.22,31
71.54,6.11,28
68.79,5.98,33

...and you'd have to separate fields at the commas to get the weight.

All of this is just to say that if you think of each line in the data file as a row in a table, it will help you understand more complicated scenarios when you get to them.

gusano79 247 Posting Shark

Seems like im supposed to initialize a counter and count how many delimiters that are used in the csv file.

There's one orange per row, right? We want to count oranges, so count rows, not delimiters.

You're currently using delimiters:

while(input.hasNextDouble())

...which may work for this simple example, but it's not correct and it will likely cause you problems if you try this elsewhere.

You had the right idea, but commented it out:

while((line = input.readLine()) !=null)

Each line in the input is a row. This will get you one row each time through the loop; easy to count.

Then focus on getting vikt out of line.

Then sum up the content ... in a total variable and then divide the total ... with the sum of the counter

You're already summing the weights:

weight.add(vikt)

...so all that should be left is to divide at the end.

gusano79 247 Posting Shark

Assuming you have somewhere to enter a postfix expression, use the postfix algorithm to evaluate it.

Are you also looking for answers to your questions in StackArray?

gusano79 247 Posting Shark

What have you tried so far?

Do you have more specific instructions? What is supposed to go into the stacks? I would guess digits.

You'll need to track some extra data, but you shouldn't need a whole third stack.

gusano79 247 Posting Shark

Anyhow, what i dont get, is how to calculate this from the csv file. I hardly believe that what they want us to do is to simply create two variables...

It sounds like it really is that simple. I read "calculate from the CSV file" to mean that you should use the data from the files, i.e., count apples and sum weights as you read the file, and divide after you're done loading. Perhaps the focus of the assignment is to be able to calculate the mean for whatever data are provided?

gusano79 247 Posting Shark

This is mostly done with what is called a recursive descent parser

See also the shunting-yard algorithm.

gusano79 247 Posting Shark

Instead of recursion like you have for the depth-first search (nadjiPut), you need to keep a list of places to visit next.

http://en.wikipedia.org/wiki/Breadth-first_search#Algorithm

gusano79 247 Posting Shark
gusano79 247 Posting Shark

It looks like rs.Open is throwing an exception, but you're ignoring it. You should do something in that Catch block to report what went wrong.

gusano79 247 Posting Shark

SQL Server's bigint type maps to Int64 in .NET, so that's right. It looks like you're trying to assign the result of the conversion where it won't fit. What type is this.bigInt?