Yrth 18 Newbie Poster

BobFx has the right idea. Technically an unencrypted zip will work, but some virus scanners and security programs unzip attachments to see if there is an executable lurking inside, so password-protected is the way to go. Just make sure the resulting zip file doesn't have the character phrase ".exe" anywhere in the filename and you should be fine. Renaming the executable itself won't work because any reputable security program is ignoring the filename and checking the digitial signatures inside the file to determine what type of file it really is, but a lot of screening programs will just as a matter of form toss anything that flashes anything that looks like an executable extension anywhere in the filename.

Yrth 18 Newbie Poster

Yep, flip the brace at line 23 and add another brace at the bottom, too - for starters. That will make it at least marginally make sense. It would be useful to know what language this was supposed to be in, too, because the initial note by James - you can't define a function inside a function definition - has merit, too - although there may be languages where that restriction doesn't apply in some cases. But in Java or C or C++ or C# you kinnae do that. This is also an excellent example of why I don't like the OTB style - it is far too easy to make mistakes like this in OTB and it hasn't served a useful purpose in two decades.

Yrth 18 Newbie Poster

I'm gonna guess Line 47 - the space between the period and the backslash. Syntax errors involving things like periods are tricky to run down at the best of times simply because the character itself is small and seems insignificant, so your brain tends to skip over it as unimportant. It takes awhile to train yourself out of that.

Yrth 18 Newbie Poster

If you're new to VS, then I would recommend initially no plug-ins. Use it for awhile. Perhaps, after three to six months, you'll be feeling something that you're missing - then look for something to fix that. I've been using VS since the oldest days (1.0) and to date I have one extension installed that didn't come with VS itself. I only have that one because it proved a convenient automated way to do something I'd been doing by hand for years. In ancient times, VS needed a lot of help, but it has grown into quite a mature product and they didn't miss much.

Yrth 18 Newbie Poster

Off the top of my head, I'd say the solution is to change line 162 from "times 510 - ($ - $$) db 0" to "times 1022 - ($ - $$) db 0". The error message is telling you that 510 - ($ - $$) is evaluating to -32 which suggests that ($ - $$) evaluates to 542. The module isalready longer than 512 bytes. You cannot pad it to 512 bytes. You are aware of this because you're specifying a block size of 1024 already. If you pad it out to 1022, then the additional two byte signature will make it 1024 and off you go.

Yrth 18 Newbie Poster

People have been debating the top-down versus bottom-up versus outside-in versus inside-out for decades. The correct answer is "none of the above". The best place to start is wherever the rubber meets the road, so to speak. Wherever the question mark is. You're writing the software to address some problem of some kind. It doesn't matter what. For the solution to that problem to exist, what is the most important question that has to be answered? Start there. If that's an assembly-language layer right next to the metal, or a network abstraction that doesn't actually exist, or a database design, or a user interface, or a search algorithm, or a peculiar species of linked list - it's something. Until that question is answered, the rest of the system is meaningless, but once you've got that question answered, then the shape of the rest of the system will be much clearer. There may be several such questions - if so, rank them and start in hardest to easiest. When the thorny parts are smoothed out it will be much clearer how many parallel streams you can get going on the rest, and where the checkpoints have to be. But most importantly, you don't spend two months carefully setting down the interface structure, database structure, input validation rules, program flow and what have you to simply find out at the end of it all that nobody figured out whether the central problem HAD A SOLUTION.

Yrth 18 Newbie Poster

Here's a bit of ancient history for you. Way back in the day one of the very first breakthroughs in image recognition was made by a computer hobbyist, and it is germaine to your problem. The main problem in image recognition is edge extraction - how does one do that? It turns out that there is a fairly simple algorithm for extracting the edges from an image:

1) Take the image as a bitmap.
2) Make a duplicate of the image.
3) Offset the duplicate one pixel horizontally and one pixel vertically from the original.
4) XOR the two images back together, pixel-for-pixel.

This was originally done for monochrome images - for a color image you will probably have to come up with some manner of comparison threshold whereby you can tell whether two colors are sufficiently similar to count as the same (and thus cancel out) rather than using a simple exclusive-or. It will also extract all the edges, which in your sample above might not give you a clean line along the jaws on either side and you'll get lips, nose, brows, hairline and other spurious elements. But you might want to give it a try - it might get you close enough to a solution that you can see a fairly simple way to clean up the result and arrive at an acceptable solution.

You could also combine this with other algorithms. There is a fairly common and popular algorithm whose sole …

Yrth 18 Newbie Poster

'Goto' exists in C++. Place a label where you want to loop to, and then "goto mylabel;" when you want to branch to it:

MyLabel:
/ Some code /
goto MyLabel;

is perfectly legitimate. Now, to head off the howls of anguish, no, the 'goto' statement is not inherently evil. The rampant abuse of it is inherently evil. When the proper thing to do is employ a control construct, then that should be the option of choice. But the goto statement persists to this day precisely because there are occasions where it is the correct control construct. Granted, they are very few, but there is no reason at all to fitzcarraldo a baroque while() - based construct to emulate a goto if all you require is the goto.

Yrth 18 Newbie Poster

I always name the main form some variant of 'Main', because that's what it is. All other forms are named by function. Exactly what the name is depends on the naming conventions set forth in the local coding standard. If I use mine, then it would be 'frmMain'. In the company for which I work, it would be 'MainForm' in the old naming convention I used several years ago, it would be 'o_Main'. I don't refer to it simply as Main() because that is the name of the entry point in Program.cs, and would thus introduce ambiguity, but it is actually a form and should thus be named according to the naming convention for forms as per your particular environment. If you don't have a coding standard, you should really set one.

Yrth 18 Newbie Poster

1) Count is used to determine how long the number is (in decimal digits).

2) Line 18 extracts the digit at the lowest significant place by calculating the value of the number as it would be if the units digit was missing [(( x / 10 ) x 10 )] and subtracting that from the number itself (eg: if x is 123, then ( x / 10 ) = 12 (integer divide which drops the fraction) x 10 = 120. 123 - 120 = 3).

3) i is not defined twice. it is the value of the highest power of 10 in the number (the initial loop calculates the first power of 10 greater than the entire number, then it is divided by 10 giving the highest power of 10 in the number). In the second loop, that power is reduced by one power of ten for each iteration of the loop.

Thus, the first for() loop calculates the lowest power of 10 greater than x. That is then decreased by one power of 10 giving the highest power of 10 actually in x. In the meantime, count is calculated which gives the total number of digits (powers of 10) available.

In the second for loop, the lowest digit is extracted, multiplied by the highest power in the number and added to the result (making the LSD in the number the MSD in the result). Then the highest power is reduced by one power ( i = 1 / 10 …

jalpesh_007 commented: good explanation. +4
Yrth 18 Newbie Poster
Yrth 18 Newbie Poster

Now, we arrive at the subject of the thread, at last. The question was, "Is that the correct way to save data?" It is the only way to save data. It is the only way to move data. At the end of the day, a hard-disk drive is nothing more spectacular than a very sophisticated, elaborate magnetic tape drive. The material is organized in a different way, there are more heads, and so on, but in terms of how they store data, a cassette tape and a disk drive are identical. The cassette tape and drive are just a lot more primitive than the disk and disk drive.

The real question is, "Is the C# Serialization implementation the correct way to save data? The correct answer is, "It depends."

If you're streaming text data or XML data, then the built-in Text and XML Serialization formatters will save you a lot of work. If you're streaming arbitrary data types, then the Binary formatter will preserve and transmit a lot of information about the data you are transmitting. These are all useful tools, and in many cases will be very useful and time-saving.

If you are, however, saving a fixed data structure of a specific size to a file over and over again, then any of the existing formatters are, at best, a cumbersome and bloated solution to the problem. Whether that disqualifies them as candidates depends on what you are prepared to sacrifice in terms of computing resources …

Murtan commented: Concise, clear and I agree with it +2
Yrth 18 Newbie Poster

Very helpful! At least to me! Thanks! Did you write that or is that from a website? Where can I read the rest of it?

There is no web-site. I wrote that, and that's all there is to it - for now. My other activities keep me tied up most of the time, but when I can find a moment, I like to toss in my two cents.

Most of what I know is synthesized from years of reading and experience, so I can't really even point you at a specific book that would be good to read. I can tell you this, though. C# is a manifestation of a style that is common to C, C++, Java, Javascript, and other languages. If you understand C#, example code in C++ or Java will be clear enough to understand, and those are both object-oriented languages, so if you're looking for books or web-sites, don't get tunnel-vision. The truth does not depend on where you find it.

Yrth 18 Newbie Poster

Scope can be confusing to some. In C or C++, it was useful to think of scope in terms of braces. In C#, this relationship holds, but with some minor but important differences.

First, there are two types of variable. Global and local. In C#, a global variable is called 'static' and is preceded by the 'static' keyword. A static variable is class-specific. That is, if it is public, it can be used as if it were a property of the class. If it is protected, it is accessible as a property of the class, but only to that class and its descendents. If it is private, it is accessible as a property of the class, but only to instances of that class. Thus, a 'public static' variable can be used by anything anywhere in a program, so these are truly global variables in every sense.

In my code, I frequently have a class that I define that specifies all of the data that can be stored in the registy, and how to read it from the registry and write it to the registry. I normally make the only instance of this class a public static variable of the main form object, so that the values can be accessed and/or set from anywhere else in the program. In general, you should constrain your use of static variable to where they are actually necessary and useful. Over-using them constrains the flexibility of your code uneccessarily.

The other type …

Yrth 18 Newbie Poster

Many people have provided answers here, and I do not wish to step on any of this good advice. I just thought I would toss in mine, because it is my opinion that the more different viewpoints you find, the more likely it is that you will find one that makes perfect sense to you.

I learned that in Calculus. They didn't teach that in High School when I was young, but the topic always fascinated me. After reading about a dozen books on the topic, it still made no sense. Most of them were textbooks predicated on the assumption that there was a professor to fill in the blanks. I finally found a book that explained calculus from basic principles, and that was my Eureka. It made perfect sense, to the point where I started kicking myself for not thinking of it myself.

To make things easier, I will put several articles in here, starting with this one, on Objects.

OOP is often thought about as a 'different' programming paradigm. It isn't really. It's the same old paradigm. People (like one example here) like to describe OOP in terms of real world things. I like to describe it in terms that make sense to a programmer, because if you want to know, you are, or aspire to be one.

An object is a data type. Boom. That's the big mystery. That's all it is. It's a user-defined data type. All data types have behaviors that …

Yrth 18 Newbie Poster

More likely environment variables that can't point to two different places on the filesystem at the same time :) I'm Borland from ages past, but found my self in an MS shop using VS, which I hadn't touched since a very painful and frustrating bout with Version 1.0. The thing actually works now, and fairly well, if you can excuse the MS penchant for trying to make their IDEs predict your next move and do it for you, thus forcing you to spend a fair amount of time undoing the damage the IDE has done to your code while it was 'helping'.

Yrth 18 Newbie Poster

Thanks ppl,
I need to keep track of the indices,
so the strtok approch wont work.

But thanks again.

The strtok() approach will work, just with a little added overhead - specifically, tracking the size of tokens you have already passed and either used or discarded.

jephthah commented: true, and good point. i was gonna say about the same thing, but i quit caring. :) +12
Yrth 18 Newbie Poster

Hello,

I am currently just getting started in learning my first programming language. I searched the web and decided to start with the book "The C Programming Language". The problem is I am already lost. I have no idea how to set up the Hello World program. I have a little experience coding in PHP and HTML but nothing like this. I'm not sure how to compile, what programs I need to do so, etc...

-Peter

For writing the code, any text editor will do, but a text editor that is designed to work with C/C++ would work better simply for things like syntax highlighting (which shows you visually the keywords and so forth). You could, however, write a program in NotePad. There is no rule against it.

For compiling the program, you need (naturally) a compiler. What is readily available to you depends on the system you have. If you search the internet, I would think that you should be able to find a Windows-compatible freeware C compiler somewhere without much difficulty. UNIX systems typically come with a compiler as part of the operating system. Typically compiler programs are called 'cc' or 'cc.exe', so the command to compile will typically start with cc.

Having said that, compiling is not the end of the road. Compiling will compile your program into 'object code'. It must then be linked with the libraries that have been used into an executable module (regardless of operating system). The linker program is typically …