deceptikon 1,790 Code Sniper Team Colleague Featured Poster

A good start in determining what's wrong is asking what it's doing versus what you expect it to do. So...what's it doing that's different from what you expected? :)

I see two problems in particular, one of which will be immediately obvious from the compiler's errors and the second will appear after fixing the first.

I'm not being obtuse, by the way. I'm trying to push you to learn how to figure out your own problems, which is a huge skill to have in programming.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Can you elaborate that part a bit ?

It's a common misunderstanding that arrays and pointers are equivalent, which causes confusion when you reach a point where object context rules (such as with the sizeof operator). The reason for the misunderstanding is that in value context, the name of an array is converted to a pointer to the first element:

int a[5];

// Prints the same address for both
printf("%p\n", (void*)a);
printf("%p\n", (void*)&a[0]);

int *p = a; // Compatible types, so no cast needed

Most of the time this conversion applies. However, this is not the case in object context, otherwise sizeof wouldn't work correctly:

printf("%zd\n", sizeof(a)); // Works like a champ

With a pointer you'd get the size of the pointer, and with an array you'd get the collective size of the elements in the array as a whole.

There are three object contexts for an array:

  • As an operand to the sizeof operator.
  • As an operand to the address-of (&) operator.
  • As a string initializer.
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

On a side note, the technique you're showing is called type punning. It's rather common in lower level code. If you're feeling frisky, an example of union-based punning to break down a floating-point value can be found in one of my teaching libraries here and here.

In the same way , if u say int *a = 5 , then a is the same as arr or &arr[0]. its just a pointer that points to a certain memory.

Noting, of course, that an array is not a pointer. Though an array name in most contexts is converted to a pointer.

In fact , you can just as well write printf("%d",c[1]) instead of printf("%d\n",*(c+i)) , Both mean the same thing to the program

Further solidifying the equivalence, you can also write printf("%d", 1[c]) because addition is commutative. Don't do that in real code though, it's an interesting yet useless trick.

Lastly , You do get a warning : initialization from incompatible pointer type when compiling

Which is cleared up with a cast. It's important to understand the warnings and avoid them where necessary. But if the warning is known to be spurious, it's best to make it go away so that the compilation log is clean. That way real warnings and errors stand out more.

somjit{} commented: thanks for the type punning side note! now i know what to search for :) +5
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The compiler is correct, varying doesn't exist at that point. You declare it in textBox1_TextChanged, but try to use it in a completely different method. Why not just use textBox1.Text directly and not worry about handling TextChanged?

MessageBox.Show("Hello!", textBox1.Text, MessageBoxButtons.OK);
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Perhaps it's just me but it seems like a lot of trouble to go through to avoid using the builtin My.Settings.

After a fashion. Certainly naive use of My.Settings is simpler than managing a configuration class, serialization, and encryption in a more manual manner. That's precisely why for simple cases I prefer the former.

However, when you run into limitations of My.Settings, working around them without switching to a different solution entirely becomes non-trivial very quickly.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What's your preferred method for saving your program's settings?

It depends on the settings and the complexity of the program in my case. For simpler things, I prefer app.config. For more complex things I prefer my own XML file using serialization. Sometimes I'll go with storing settings in a database. The registry is not recommended.

Is there a preffered industry standard?

Not a single one. :)

Does .Net provide a namespace for reading writing a programs settings?

Yes. The API that facilitates app.config is exposed for you to use. However, unless you're using it in conjunction with app.config, things get hairy. I vastly prefer managing custom XML or INI separately.

As VS creates settings in XML in the app.config file should I sipmly take this as preferred.

That should be your default preference when all else is equal.

J.C. SolvoTerra commented: This makes me happy as I don't have to change my personal preference hehehe +3
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

In terms of e-peen points, you're doing okay. What really matters is the intangible reputation you earn that is what people who matter think of you. And that kind of reputation takes time.

Were I concerned about reputation, I'd wonder what people thought about a public annoucement of leaving after less than a month of not getting enough weenie points. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Is that a Julian date format? I was assuming you had something like an ISO 8601 formatted date, but this complicates matters.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Since you're already using C++/CLI, why not initialize a DateTime object with the String^ and then use the ToLocalTime method?

What exactly does the string contain? Is it a standard UTC format?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Playing with the structure examples in the book reminds me of accessing attributes to a python Class

That's not a bad analogy. A structure in C++ is just a class with different default access (public instead of private). A union is different in that all members of a union share the same block of memory rather than each member having its own block of memory.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Well, yes. I used a SQL variable since it's a better idea to use parameters to your query rather than glue everything together directly as in your first example. But you could also replace @schoolYear with your string pasting:

"select count(*) from tblSchoolYear " & _
"where schoolYear = 'SY " & Trim(txtAddSchoolFrom.Text) & "-" & Trim(txtAddSchoolTo.Text)
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

For this I'd select the count of matching records:

select count(*) from tblSchoolYear where schoolYear = @schoolYear

If it's greater than 1, you have duplicates and can show a message box. However, that particular query strikes me as producing false positives unless the schoolYear column is largely unique. You'd likely need to add another condition to tie it to a specific student.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'm not entirely sure I understand the problem. A bool property will display appropriately as a checkbox by default in a DataGridView. So you'd add such a property:

bool Availability { get; set; }

Then convert the result of the combobox as necessary (varies depending on how you've got the combobox set up):

// If the items are the strings "Yes" and "No"
Newvideo.Availability = comboBox2.SelectedItem.ToString() == "Yes";
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

if we don't use return then there is no value returned to the function?

It's not quite that simple. For extra credit, try to explain what's happening here:

#include <stdio.h>

int foo()
{
}

int main(void)
{
    printf("%d\n", foo());
    return 0;
}
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The two examples are functionally identical. Which one you'd use depends on which fits better with the rest of the code.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Bounded array means static it it?

"Bounded" typically means one of two things:

  1. The size of a container is fixed and cannot change.
  2. Accessing indices outside of the container's range will produce an exception.

Can you clarify what you mean by "bounded"? I'm also not familiar with that as any kind of standard terminology. IIRC, the C++ standard only mentions "bounded" in reference to numeric ranges and syntax grammar; nothing about arrays.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I don't think that the choice of Padme as the "lucky lady" was inherently bad.

Not inherently, but very poorly executed. ;)

This is slightly off topic but I just went to see transformers today and it pains me how movies these days seems to be all about fitting as many special effects as possible into the film.

Rear Window is one of my favorite movies, and a stellar example of the exact opposite of our current special effects extravaganzas. Special effects are icing on the cake, but a compelling plot and interesting developed characters are the core.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Well, the problem is that they needed to create this very critical romance between Anakin and Padme in order to get Luke and Leia conceived. So, you can't blaim them for putting that one romance in the prequels.

Hmm, they needed to get Luke and Leia conceived, that I'll agree with. But I can blame them for the choice of characters as it didn't have to be Padme. The whole Padme thing seemed poorly thought out to me. It struck me as "well, we have this high profile female character, and this critical male character, and the male character needs to get some for the next three movies to make sense. Let's put them together in a weird way because it would be too much trouble to think of a more realistic progression of events!"

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

1)They didn't too bad... but yes they could explain more like they do in their video games.

Or they could not explain it. That's a huge problem with sci-fi and fantasy these days: authors try to explain phenomena in their world when it's completely unnecessary and often detrimental to the story.

2) I am not into romantic scenes in movies, so I don't really have anything positive about it.

Romance is fine, provided it's done in a way that doesn't break immersion. One thing good authors learn very quickly is that romance is freaking hard to get right.

He would be a good pick when you think about it... only if he played a retired version of him...

The Han Solo from the books is a badass despite not being runny shooty as much anymore. I'd be all for them going that route.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

But OTOH they can't be worse than the prequels.

O ye, of little faith. It could be much worse than the prequels. In terms of suckage, the prequels failed in three big areas:

  1. Trying to explain the force.
  2. Shoehorning a romance in the unlikeliest of places.
  3. Comedy relief character(s) that only pissed us off.

My personal opinion is that Disney could easily acquire rights to any of the book series for Star Wars and have an instant blockbuster storywise. The Thrawn series or X-Wing series come immediately to mind as good choices.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Honestly, I wouldn't worry about it unless you're under some harsh memory constraints.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Why exactly do you need this? Unless you're writing a library (in which case a wrapper is the appropriate solution), it's more a matter of careful coding and checking invariants where necessary.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

For smaller projects I place enums in a project-level Enumerations.cs file. For larger projects I tend to break things down into folders where each folder holds related stuff and might have its own Enumerations.cs file.

For tiny projects or strongly self-contained classes where only the class needs access to it, I might place the enum in the same file as the class.

The important thing to do is make sure that the structure of your files makes it clear how much visibility an enum has. Putting it in the same file as the class that uses it the most strikes me as a confusing file structure.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Because Microsoft couldn't reach full conformance in time and they created their own priority list of features (which includes C++14 features) based on what they believe customers want most.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

It really depends on what kind of code you'll be working with. If you're only doing system level stuff, learning UI components isn't as important. If you're only doing the front end of applications, learning the niggling low level features isn't as important. Repeat ad infinitum for whatever feature you can find. That said, a well rounded programmer tends to be a better programmer in general.

Some aspects of a language like control structures and declarations are fairly universal, but you can get comfortable with those common aspects in a day or less.

So the first question to ask as concerns what the important features to learn are in a programming language is: how am I going to use this language?

Becoming a good programmer is an easier question. Practice makes perfect. Read/understand lots of code, write lots of code, try different things as often as practical, and associate with good programmers whom you can learn from.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

As a fresher, take what you can get and build a portfolio of experience. The big bucks come later, regardless of what schools tell you. The days of a noob entering the workforce with an enviable salary are long gone.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The WinForms timer only runs in the UI thread. If you want to run in another thread, use another timer. I'd recommend System.Timers.Timer.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Apologies, I assumed you wanted the System.Timers timer. But it looks like you're trying to use the System.Windows.Forms timer:

var MyTimer = new System.Windows.Forms.Timer();

This may be of use to you in chosing which to utilize.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The .NET framework has three Timer classes. One is in System.Windows.Forms, one is in System.Timers, and one is in System.Threading. When you include more than one namespace with the same class name as a meber, the type must be fully qualified to resolve the ambiguity:

var MyTimer = new System.Timers.Timer();
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

What actual real type could I use instead of var?

The type is Form1, since that's the name of the class, and it derives from System.Windows.Forms.Form:

Form1 instance = new Form1();
deceptikon 1,790 Code Sniper Team Colleague Featured Poster

So if you dont declare protection it is default set to private?

Enumerations and interfaces are public by default when nested in a class. Top level types default to internal. Everything else is private by default.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Provided the DLL references appropriate assemblies for your presentation (WinForms or WPF), displaying a form and returning the result is a no-brainer. The key will be deciding how you want your application to call into the DLL. It can be as simple as exposing a public dialog form and doing this:

Using dlg As New MyDialog(initStr)
    If dlg.ShowDialog = DialogResult.OK Then
        TextBox1.Text = dlg.Result
    End If
End Using

That's actually how I'd do it, and how I've usually chosen to do it before (I've done this a lot since extensions and customizations through plugin DLLs are something I do often) because it cleanly separates responsibility.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Why don't you think it's correct?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

If you don't want to use any .NET languages, then ASP.NET won't be useful to you. There's a little bit of a dependency there. ;)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

You can program and do not need to understand what algorithm/data structure is

Actually you do, even if it's informally. Algorithms and data structures are the core of programming. Any time you process data somehow, that's an algorithm. Any time you collect data in storage, that's a data structure.

int[] stuff; // Hey, a data structure!

...

// Oh my, an algorithm!
for (int i = 0; i < n; i++)
{
    sum += stuff[i];
}

Algorithms and data structures aren't limited to the "offical" or "standard" ones that books will describe, though you can learn a ton about how to design your own by studying them.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

getline also gets input from the user...and from the same place (cin), which is the root of your problem.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

cin>>x reads the first word in the stream. getline(cin,x) reads the rest of the line. If there's nothing else on the line, getline won't read anything.

It seems like you're expecting these two operations to not remove what they read from the stream, which isn't the case.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster
cin>>in;

This reads the first word in the stream.

getline(cin,in);

This reads the rest of the line in the stream. Remove the cin>>in; line and getline should include all of the user's input rather than a part of it.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I'll answer your question with another question: what does string.compare return and what does that value represent?

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

The library user would never - ever include any of these files.

Provided you can guarantee this, then it's only a question of transparency for maintenance programmers. All in all, I see no problem with breaking internal headers down like you've suggested. An important lesson is that best practice is not always practice. But care must be taken when deviating from best practice, and it looks like you're taking great care in doing that. :)

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Yes. There are a number of APIs out there, including one that comes with Office, that will support this functionality.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

However, for the short term, the idea was to split this monster up into functionally related groups using the include mechanism. What I hope to learn here is if there are any hidden dangers in this technique.

Provided the "modules" are independent enough to justify breaking them down, or the breakdown is internal and not exposed to users of the library, it's all good. The key with organizing a library is transparency. A user of the library must be able to figure out what headers to include for which functionality with relative ease.

If users end up asking "what the heck do I include to do XYZ?", your library is poorly organized.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Every job asked for a Bachelors plus a large handfull of other programming skills I was lacking.

That's normal, unfortunately. HR departments are usually the first gatekeeper and will demand between reasonable and unreasonable credentials. This is where knowing someone on the inside is a good thing.

The reason for my question here is that I've heard it may possibly be a difficult environment for women and older programmers

As always, it depends. I have yet to see any significant difficulties for women in general, provided we're talking about real difficulties rather than petty ones. ;) A larger issue would be older folks. It's unfortunately not uncommon to perceive older people as technological dinosaurs who are set in their ways and refuse to learn new things. You may find yourself having to defend against that mindset in competition for a job with younger people.

as a newbie 50+ woman when graduating will I be a guppy in a pool of sharks LOL?

That's the case as a newbie in general. However, as a 50+ woman, you probably have quite a bit of education and experience in other fields that can be leveraged to give you an advantage over your ~20 year old peers fresh out of high school and college. Exploit that as much as you can. :)

A woman friend of mine works in IT and has found it pretty tough.

IT is a tough field, period. Usually when people ask …

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

At this point the only benefit of a built-in array would be slightly more concise declaration syntax. But the functional benefits of std::array blow that out of the water.

As a rule of thumb, I'd say prefer std::array until you have a good reason to pick a built-in array.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Far be it from me to put forth a logical fallacy (which guarantees that what follows will be exactly that, I'm well aware), but can you point out a forum that implements a voting system which requires some form of comment?

You have forums that support a reputation system with comments, and forums that offer only non-anonymous voting, but I've yet to see one that has both a reputation system (or a commenting system) and a non-anonymous voting system. In fact, voting from what I've seen has been overwhelmingly anonymous.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

it protect you and the ones that using your site.

Not really, it just saves us extra work. Daniweb's moderation team is easily the best I've ever seen, and I have no doubt we'd snuff out unsavory types in short order with or without this feature. But with the feature, it gives mods breathing room to participate as regular members instead of always doing moderation work.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Actually, if it implements tail recursion optimization, then you should be ok!

Not really if the goal is to avoid memory use. TRO still introduces hidden variables. Fewer variables, sure, but the purpose of a swap without a temporary is completely defeated.

Keep in mind that the primary goal of these tricks is to avoid the negligible cost of a temporary variable. If your solution doesn't produce this saving, it's a non-solution to the given problem.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

I actually can think of one way that does not require any extra variables, works for any datatype and is also very natural.

There are no explicit variables, certainly. However, there's a strong chance that memory will still be allocated to each parameter for each recursive call. So technically you're using more memory than a traditional imperative swap with a temporary.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

Besides, 5 posts, 5 days of membership, and 15 rep points is not that hard to earn.

IIRC, it's 5 posts + 5 days or 15 reputation points. So you can unlock functionality with the default rep allocation, or you can unlock it sooner by earning rep.

deceptikon 1,790 Code Sniper Team Colleague Featured Poster

While that may work in Java, it's horribly broken in C due to undefined behavior. Further, you've introduced a requirement to check for integer overflow.

For all of the mental gymnastics involved in devising ways to swap without a temporary (though these days everyone just Googles for solutions to look smart), nobody has come up with a general purpose solution that's even comparable to using a temporary, much less superior.

Finally, if you're micro-optimizing to this granularity, you've probably lost perspective as concerns performance and memory usage.