gusano79 247 Posting Shark

I'm not 100% sure, but I have a theory. Are you pressing ENTER to finish entering the price? It seems like nextDouble isn't consuming an ENTER-press, so the following call to nextLine sees it, and assumes you entered nothing for the category. Try using nextLine to get the price and convert it to a double separately... if that works, then my theory is correct.

gusano79 247 Posting Shark

error C2065: 'StreamReader' : undeclared identifier

Add this:

using namespace System::IO;

error C2065: 'inData' : undeclared identifier
error C2227: left of '->EndOfStream' must point to class/struct/union/generic type

These happen because of the StreamReader problem.

The following isn't in your list, but it'll come up:

error C2039: 'searchResult' : is not a member of 'Hardware_Store::Form1'

The member is searchResults, note the plural. Change it in the few places it's not right.

gusano79 247 Posting Shark

Off the top of my head:

  • Use HTTPS, if you can.
  • Authenticate without actually sending the password, as in a challenge/response. This isn't completely safe (e.g. it's still vulnerable to man-in-the-middle attacks), but it's much better than sending a cleartext password.
Gribouillis commented: good link +13
gusano79 247 Posting Shark

Aha! I found an example of how you can customize a locale.

A quick test:

#include <iostream>
#include <iomanip>

using namespace std;

struct CustomSeparator : numpunct<char>
{
   char do_thousands_sep() const { return ','; }
   string do_grouping() const { return "\3"; }
};

#define AMOUNT 250714520349508480.0

int main()
{
    cout << fixed << setprecision(2);
    cout << "Normal: " << AMOUNT << endl;
    cout.imbue(locale(locale(), new CustomSeparator));
    cout << "Custom: " << AMOUNT << endl;
}

For me, this displays the following:

Normal: 250714520349508480.00
Custom: 250,714,520,349,508,480.00
gusano79 247 Posting Shark

Extra right round bracket here:

"[ClassifiedUnitValuePerm] DOUBLE), " & _
gusano79 247 Posting Shark

Perhaps something like this will work for you:

DECLARE @enddate DATETIME
SET @enddate = GETDATE() -- or whatever end date you're interested in

SELECT ...
WHERE a.IPI_Ref_Date BETWEEN DATEADD(YEAR, -1, @enddate) AND @enddate
gusano79 247 Posting Shark

String.IndexOf in the .NET Framework is essentialy the same thing as Java's String.indexOf, allowing for platform differences.

gusano79 247 Posting Shark

Depends... if you just need to draw it rotated using GDI+, you can use Graphics.RotateTransform and draw using the original, unrotated coordinates. Otherwise, I think you're stuck doing it yourself.

gusano79 247 Posting Shark

I plugged a monitor directly to the board and recieved no signal to the monitor

I don't see any onboard video for the M4A77 on the Asus website... what did you plug it into?

I installed a known good GPU into the board and used that and still no signal going to the monitor. (light never turns green)

The bad one may have fried the PCIe x16 (that's the slot it went into, right?). Do you have an older video card you could test in one of the PCI slots?

gusano79 247 Posting Shark

Hm. localhost is the same as 127.0.0.1 so I'd expect the same result. If it couldn't connect to your server (for example if it was off), you'd get a different error... Hmmmmmm.

I was able to get a similar command to run for my local MySQL over here...

Unknown MYSQL Server host '127.0.0.1'--databases

Notice that there is no space between the host name and --databases in the error as reported; are there appropriate spaces in your manual command line?

savedlema commented: thanks. please check my reply. +2
gusano79 247 Posting Shark

First step is to see what the console output says; open up a command window and run it manually.

gusano79 247 Posting Shark

Are you looking for this kind of algorithm?

gusano79 247 Posting Shark

What behavior are you expecting and what are you actually seeing? It's easier to help if you give specifics.

Meanwhile, here are some comments:

trying to use recursion

Is there a specific requirement that you use recursion? If not, there are other approaches I'd recommend exploring first.

to find the occurence of a specific character in an array of characters

Do you mean a) find the first occurrence, b) find the last occurrence, c) find any occurrence, or d) count the number of occurrences?

From the name characterCounter, I imagine it's d), but the code doesn't actually count occurrences of the given character.

characterCounter(test, searchChar, test.length-1)

I generally find starting at the beginning results in code that is easier to understand.

if(t.length < 0)

Arrays never have a length less than zero; not sure what you're trying to do with this.

gusano79 247 Posting Shark
  1. NSLog works much like printf; %d is for integers, %f and %F work for both floating point types, and BOOL is just an integer, so use %d.

  2. double can handle more precision; try a number with more digits.

  3. That's how the language works; you have to write NSString *personOne, *personTwo;. It might help to think of "pointer-ness" as a property of the variable, not the type.

  4. Any integer type will do, like int i = 23; i <<= 2; should leave 92 in i.

MareoRaft commented: if %d is for integers, what is %i for? +3
gusano79 247 Posting Shark

To sort as part of your query, use an ORDER BY clause.

Does that help? If not, please post some code so we can get at specifics more easily.

gusano79 247 Posting Shark

Have you looked at these methods?

gusano79 247 Posting Shark

Android Developer Guide: OpenGL is a good place to start.

If you're interested in a high-level API, there are libraries out there like Unity and jMonkeyEngine.

gusano79 247 Posting Shark

if I put an if clause in the swap method to check and see if array[a] is != to array[b] I find several instances where they actually are equal and if I don't count those with my counter the the number of viable swaps decreases.
...
whether or not I should consider them viable swaps or not since the computer is doing them then it is using up resources therefore they should be counted.

As far as the swap method is concerned, I'd have it just do the swap, whether the elements are equal or not. This keeps it simple and clear--when you say "swap," you'll want it to really mean "swap," not "swap except if the elements are equal."

But that doesn't answer your question: Should you check for equality before swapping? I wouldn't. It would only matter if the swap operation was inefficient, but we're talking Java here, so any complicated data structure will be represented by a class, and you'll be swapping references to instances of that class, not the instances themselves.

And the other half of your question: Should you count swapping equal elements? If you don't check for equality, then you have to... but you'd want to even if you were checking. Counting swaps is more about the characteristics of the algorithm than it is about sorting any specific data set--if the algorithm says to swap the elements, you'll want to track it regardless.

bguild commented: Well said +6
gusano79 247 Posting Shark

SDL and Allegro aim to provide a more or less complete game programming library, but you might also consider combining several separate libraries that focus on smaller areas--especially if the general-purpose libraries don't quite do what you want.

A loose assortment of links to get you thinking: Chipmunk, GLFW, OpenAL, Horde3D, Lua, PhysicsFS, SQLite, Ogre3D, Guile, Irrlicht, irrKlang...

gusano79 247 Posting Shark

Before we talk about how to guess letters and replace the *s, there are a number of problems in the code that should be addressed first. I might seem to get a little pedantic here, but clearing up these issues will make the code shorter and easier to understand, as well as clear up a few misunderstandings about how some of these things work.

From the top:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

You're only actually using the System namespace; remove the rest of the lines so it's clear which parts of the library you're actually using:

using System;

At the start of Main:

static void Main(string[] args)
{
    string Name;
    string gameWord;
    bool[] boolLetters;
    char[] wordArray;
    char[] letters;
    char PlayerGuess;

This advance declaration is required in C, but not C#. In most cases, I prefer to see variable declarations at the same point they're first used, like this:

string Name = Convert.ToString(Console.ReadLine());

That way I don't have to go back to the top of Main to remind myself that Name is a string.

(Note: I'm editing my copy of the code as I go here, so some of the following recommendations will make more sense if you're following along with the edits)

This is a little verbose:

char[] letters = new char[26] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', …
gusano79 247 Posting Shark

How are you running your normal database queries (or do you have any)?

SqlCommand.ExecuteNonQuery and SqlCommand.ExecuteScalar are simple enough if you're using plain ADO.NET.

You can also wire up stored procedures to a LINQ data context or an Entity Framework data model.

gusano79 247 Posting Shark

The authentication in the sample project is just a stub, but you knew that already because you're trying to replace it with a database lookup. And you knew where to find the authentication code, which suggests you figured out where the login information was going.

I'm not sure what you're asking for here, unless you just stumbled across the authentication code and are wondering how the login info gets there. If that's the case, then here's how I'd trace it:

  1. Pick one of the Web site projects; for purposes of this discussion, I'm going to use www.domain1.com
  2. Users log in at Login.aspx with the "Login" button
  3. Button click handler is in Login.aspx.cs at btnLogin_Click
  4. The handler calls Login, which is part of the base class PrivatePage, in the SSOLib project (PrivatePage.cs)
  5. PrivatePage.Login calls Authenticate in AuthUtil (AuthUtil.cs)
  6. AuthUtil.Authenticate makes a Web service call to AuthService.Authenticate, in the www.sso.com project (AuthService.asmx, ultimately App_Code/AuthService.cs)
  7. AuthService.Authenticate calls UserManager.AuthenticateUser (App_Code/UserManager.cs)
  8. UserManager.AuthenticateUser scans through a hard-coded list of three users to see if you entered one of them.
brian71289 commented: Great Job! +0
gusano79 247 Posting Shark

If Feed is a method, it would look something like this:

public void Feed(string FoodType)
{
    if (Food != "Unknown")
        Console.WriteLine("{0} eats some {1}.", Name, Food);
}

public void Feed()
{
    Feed("Unknown");
}
gusano79 247 Posting Shark

How do you want this general property to work? Will users of this class be providing the storage type name?

DrMAF commented: yes, exactly. +0
gusano79 247 Posting Shark

error: expected ';' before '::' token.

You have to get the iterator from the class, not an instance. Try this:

for (std::string::iterator it = (s.words_input).begin();

error: 'it' was not declared in this scope.

This one disappears once you fix the above problem.

Vasthor commented: thnx +0
gusano79 247 Posting Shark

I was wondering if those @ numbers mean that they all point to the same thing

I'm saying I don't think they do. Now that I know you're using DLL Export Viewer, I can say that with certainty. The two hex columns after the name are "address" and "relative address"--these tell you where the names point.

but I will assume you are correct.

Don't assume, we know what that does :)

I've checked off Show Unmangled Names only.

Well, different compilers mangle names differently. I think one of two things is going on here: Either DLL Export Viewer doesn't officially support unmangling the output of whatever compiler was used originally, but it does well enough that all it leaves is the parameter size at the end; or maybe it's adding the parameter size to the name itself, though that seems unlikely.

gusano79 247 Posting Shark

http://www.connectionstrings.com/ is a useful resource if you're having trouble getting the connection strings right. Check out their FoxPro page.

gusano79 247 Posting Shark

vb error within the SQL command

That doesn't exist.

VB is complaining about VB code. It doesn't parse SQL code--you won't find out if it's correct or not until you get the VB part straightened out so that it compiles and runs. You'll get a runtime exception if the SQL isn't right.

An experiment to try:

Int.parse(TextBox1.Text)

You have the above expression inline as part of the string definition. Try assigning the result of this expression to a variable in its own line, and use the variable instead when you're concatenating strings. See which line the compiler complains about.

But wait:

"UPDATE Raw_Materials SET Quantity=+('" & Int.parse(TextBox1.Text) & "') WHERE Part number=('" & ComboBox1.SelectedItem & ") "

So you're parsing some text into an integer, and then immediately you convert it back to text? Why not use TextBox1.Text directly? If you're using Int.parse to guarantee that it's a number, that's not a best practice. Better: Set up the text box so it only allows numeric input.

SET quantity+(number). .... Is this the correct way to add values to a row in a database?

No.

A standard SQL UPDATE statement would look more like this: UPDATE Raw_Materials SET Quantity = Quantity + ####

If you're able to run queries directly in your database (exactly how will depend on what kind of database it is), you can test your SQL separately first. I think that's a good idea; it's what I do …

gusano79 247 Posting Shark

Consider using something like an XmlDocument instead of using the writer directly. It'll be easier to do arbitrary things to your bookmark list with the XML DOM.

gusano79 247 Posting Shark

Are both projects set up as 'Windows Forms' projects? One of them should be a 'Class Library' project, probably form2.

gusano79 247 Posting Shark

Here's your problem:

int main(){
D* d;
d->add();

You've declared D* d, but you never assign it a value. It could be pointing anywhere. Then you go and try to use this uninitialized pointer. That is an excellent way to get a segfault.

I compiled this using GCC, and it said "warning: 'd' is used uninitialized in this function". Do you get a warning like this? If it does, you need to pay more attention to your compiler. If it doesn't, get a new compiler.

This is not the only place you're using uninitialized pointers; I count at least two more.

Bonus comment:

#include "A.h"
#include <vector>
#include <iostream>
using namespace std;
class A;
class B {

In B.h, when you include A.h, you're including the definition for the A class already. No need to declare class A; after that. Again, there are a few places you're doing this.

gusano79 247 Posting Shark

Without code to look at, my best guess is that main.h doesn't have an include guard and is somehow getting included more than once.

gusano79 247 Posting Shark

Hi guys,

I'm trying to use the random number generator as part of the GSL library and it is working fine for a few hundred 'rounds' of my code (it is used quite a few times per round) but then i get an error message in the command window:

gsl: rng.c:46: ERROR: failed to allocate space for rng state
Default GSL error handler invoked.

Please post the part of your code that is actually generating the random numbers.

My guess is that you're creating a new generator every time you need a random number, and you're not destroying it after you're done. If that's the case, the allocator will happily reserve whatever amount of space it needs for each generator, and eventually you'll run out of memory.

gusano79 247 Posting Shark

A direction you might look in is your network card's scandalously-named promiscuous mode.

gusano79 247 Posting Shark

This line:

Decimal.dTemp = 0

There shouldn't be a dot there; it tells the compiler to look for a member of Decimal called dTemp .

You meant this:

Decimal dTemp = 0

But that's C#... how about:

Dim dTemp As Decimal = 0
gusano79 247 Posting Shark

Depending on your application, it might not matter too much, but there can be a significant performance penalty for getting all twenty fields instead of the four you need. Not just because of the amount of data sent across the wire, but also if you have multiple instances of your application running, it's that much more load on the database server.

It also keeps your application cleaner for greater maintainability. Next time someone looks at your code--and this could be you, six months from now, when you've forgotten everything =)--they won't have to wonder "why aren't we using these other sixteen fields?"

zachattack05 commented: That's a good point +5
gusano79 247 Posting Shark

1. there is an elegant way of doing things more clean and not a list of files that i very confusing?

A common practice is to use a different folder for each namespace, with one type per file. This is automatically supported by some IDEs--Visual Studio and SharpDevelop come to mind.

2. its a good idea of lets say - open a abstract class file and add - i think its called - nested classes for all the classes derived from it?

I don't recommend using nested classes too much. I prefer to stick to one class per file; it makes things easier to find.

3. side-Question: there is a way of tell the solution to automatically set the folder-usings above every class i create?

Your IDE may have some sort of template it uses when generating new classes. If it does (again, VS and SD do) you can probably customize this template to start out with whatever content you want.

gusano79 247 Posting Shark

They could say it is false because the base class is not modified.
It does not add functionality to the base class; it adds functionality to the class inheriting from the base class.

Read the statement again:

"Inheritance increases the functionality of a base class by adding additional features to its derived class."

You can use inheritance to add features to a derived class, but there are other possibilities.

Do nothing (not very useful, but legal):

class Base
{
    public void DoSomething()
    {
        // insert code here
    }
}

class Derived : Base
{
}

Change behavior:

class Base
{
    virtual public void DoSomething()
    {
        // insert code here
    }
}

class Derived : Base
{
    override public void DoSomething()
    {
        // different code here
    }
}

You can actually remove functionality:

class Base
{
    public void DoSomething()
    {
        // insert code here
    }
}

class Derived : Base
{
    new public void DoSomething() { }
}
gusano79 247 Posting Shark

Problem is, it appears the #ifndef and #define tags aren't stopping Secondary.cpp from redeclaring HelloWorld.

Does anyone know what I did wrong?

Your include guard is correct, but it is designed for a different kind of problem, like this:

// Main.cpp

#include "Main.h"
#include "Main.h"

int main()
{
    cout << HelloWorld;
    //HelloEarth();
}

The above code will still compile fine because you've protected against Main.h being included more than once in the same compilation unit.

Each CPP file is a separate compilation unit, so both Main.cpp and Secondary.cpp are going to be able to include Main.h , even with the include guard.

The error message actually says multiple definition, not declaration. The problem isn't that you've declared HelloWorld in the header, it's that you've given it a value there. Because each CPP file includes the header separately, you've given it a value twice--this is what the compiler's complaining about.

You can still declare HelloWorld in Main.h , and you must if you want to refer to it from multiple CPP files, but you can only give it a value in one place. It doesn't really matter where, as long as the file that contains the definition is compiled into the final executable.

Here's one way you could do it:

// Main.h

#ifndef MAIN_H
#define MAIN_H


#include <iostream>
using namespace std;
#include <string.h>

extern string HelloWorld;
void HelloEarth();

#endif
// Main.cpp

#include "Main.h"

string HelloWorld = "Hello World!\n";

int main()
{
    cout << HelloWorld; …
Chuckleluck commented: Did more than just gave me the code to fix the error, he explained the causes very clearly and overall did a great job replying. +2
gusano79 247 Posting Shark

When the window is created where is the center of my cordinate system ? is it at the top left corner or at the center of the window screen?

That's up to your code to decide. Look at the call to gluOrtho2D; in this case, you're putting (0, 0) at the bottom left of the window.

how will i know how much i have to translate to move like 1cm on my screen towards right?

You should be able to use glutGet to find out the screen size. For example, between GLUT_SCREEN_WIDTH, GLUT_SCREEN_WIDTH_MM, you should be able to figure how many pixels are in a centimeter.

Don't forget that your coordinate system may not directly correspond to pixels; you'll need to get GLUT_WINDOW_WIDTH to compare with your orthographic matrix.

gusano79 247 Posting Shark

I can't seem to find out if it's possible to encode JSON in C#, are there any libraries out there?

The main JSON page has a giant list of links to libraries in all sorts of languages, including C#. How hard did you look, really?

gusano79 247 Posting Shark

i was trying to move a circle inside a square and was unable to do it

Don't despair; you're almost there. (Hey, that rhymes!)

What you're missing is the fact that glutMainLoop does not call your display function repeatedly. You need a way to tell the GLUT code that it's time to draw the scene again. Try clicking in your window, or dragging another window over it, and you should see the circle move--that's because the OS is telling your program that it's time to redraw everything, and your animation code is in the display function.

glutMainLoop never returns, though, so you have to do this in a callback. It can be educational to experiment with putting the call in various callbacks, but for a smooth, framerate-independent animation, it's best to use a timer callback, which you register with glutTimerFunc.

When you have that working, you'll notice that if you click or drag other windows around, it will sometimes throw in an extra redraw, so your animation isn't as smooth any more. That's because your animation logic (the lines starting with if(movRight)) is still in the display function--you only really want that happening in your timer function, so move that code there.

gusano79 247 Posting Shark

I have investigated using an IntPtr: I have no way of knowing the length of the data coming out of the dll method so I can't successfully copy the data to a byte[]. If there was a way to iterate over the data IntPtr provides access to then I would be able to find the string null terminator and copy to content to a byte[].

Is there a way to manipulate IntPtr to get a byte[] of the method output?

You can use Marshal.ReadByte to locate the string terminator, along these lines:

int length = -1;
while(Marshal.ReadByte(ptr, ++length) != 0);

Then you can use Marshal.Copy to get the array:

byte[] bytes = new byte[length];
Marshal.Copy(ptr, bytes, 0, length);

And there you have it.

Extra credit: Turn this into a custom marshaler for UTF-8 strings.

PoovenM commented: Clean, simple answer. Thank you :) +6
gusano79 247 Posting Shark

The first few sections of this page may be relevant.

gusano79 247 Posting Shark

Hi :)i heard about mvvm & mvc design pattern but when i search for them i get only things that relative to asp & wpf... and those are (if i dont get it wrong) web developers

MVC = Model/View/Controller

You're getting a lot of ASP links because of Microsoft's ASP.NET MVC, which is an implementation of the MVC design pattern for ASP.NET.

MVVM = Model/View/ViewModel

This one is much more closely tied to Microsoft products; it came from them originally as a pattern for use with WPF. It's not as widely applicable as MVC yet, but that's only because it's newer.

should i leave the search for knowledge on those patterns?
i dont know nothing about them, i just heard on them and thought if i need to learn about them

These are useful architectural patterns; I would recommend you at least become familiar with the basic MVC pattern, perhaps leaving the more technology-specific patterns and frameworks for when you actually end up using them.

gusano79 247 Posting Shark
gusano79 247 Posting Shark

Anyone know of a way to obtain an MD5 checksum of a file (through HTTP) before downloading it through HTTP?

Only one way that I'm aware of: Request the file using a HEAD request instead of GET --the server should only return the HTTP headers for the file. One of the possible headers is Content-MD5 , which is a base64-encoded MD5 hash of the content. I say "possible" because it's entirely up to the server which headers it returns. If a server provides it, great; if not, you're out of luck.

pseudorandom21 commented: tyvm +9
gusano79 247 Posting Shark

Hi guys
i'm trying to just do a simple email/password validation on two text boxes.
This code runs but when i type in a correct email address it throws an error "Object reference not set to an instance of an object." on AdAcc.InsertCommand.Connection = OleAcc;

This is happening because AdAcc.InsertCommand is null. You need to create a new OleDbCommand and assign it to AdAcc.InsertCommand. The linked MSDN page has an example.

gusano79 247 Posting Shark

i have made a program with this algorithm but its not working properly my code is given below can you help me to remove the errors

There's only one compiler error: You can't call getch with any parameters, like you are when you say getch(f) . The only call you can make is getch() . But the real error is that you can't use getch to read from files. You probably want fgetc instead.

Other problems that you should correct: void main() isn't proper C; it should be int main() --with a matching return at the end, of course. if(f != 'NULL') is wrong. NULL isn't a character constant, it's a symbol defined in stddef.h . You meant if(f != NULL) . while(ch = fgetc(f) != EOF) is potentially confusing. You might want to write while((ch = fgetc(f)) != EOF) , which makes it clear that you're comparing the result of the assignment with EOF , instead of assigning a truth value.

gusano79 247 Posting Shark

It doesn't say anything to the CPU; this directive doesn't generate any code. It's only there to help the assembler. Here's an article that goes into some detail with a few examples.