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
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
The problem I am having is that the program will run, and go through the first loop, but when it comes to the point of calling the functions, it just skips over them.
Look at these lines carefully:
float sum(int sales[], int size); cout << "The sum of the Figures you entered is " << sum << endl; float average (int size, float sum); cout << "The average of the figures you entered is " << average << endl;
Those are declarations. Your code never actually calls the functions. You should also see some warnings generated around here, too (for what it's worth, GCC complains about the cout
lines). Pay attention to compiler warnings; they're usually trying to tell you something important. What does your compiler say about this code?
He's expecting the compiler it to align all instances of this structure to 4-byte boundaries via padding. I'm not entirely sure if this should actually change the value returned by sizeof().
I'd say that to be a successful software engineer, you should at least be comfortable with basic algebra. You've got that covered already, so stopping now shouldn't hold you back.
But.
Any math class you take or technique you learn will prove useful and make you better at software engineering. Some mathematical areas may seem highly specialized, but you might be surprised at how widely some of the concepts from those areas can be applied.
My recommendation, then, is continue to take math classes as long as you find them interesting and rewarding, and stop when they start turning into pain and drudgery.
It almost doesn't matter what the topics are, but there are a few standard classes that you should probably take at some point if you choose to continue with the math: Linear algebra, and symbolic logic. Linear algebra will tone up your matrix and vector muscles, and there are a variety of techniques that come from there that are handy to have in your back pocket. The logic course is likely a philosophy credit, and you'll probably be ahead of the class because of your experience with programming, but it should help formalize your thinking and fill in any gaps you might have.
if i open with notepad the original file ( from that i obtined that .h ) and the outputed file .. they are the same.
But if i open the outputed file it is closing when i start it :|
If they're really the same, there shouldn't be any difference, so something must have changed.
I tried :
std::ofstream file; file.open("ADRIAN2.EXE"); file.write( (const char*)nosize, nosize_size); file.close();
Hm. Have you tried opening the file in binary mode? You'll definitely want to do that with an executable.
Ah, Visual Studio Fatal Error C1010.
From the linked article:
If you do not use precompiled headers in your project, set the Create/Use Precompiled Header property of source files to Not Using Precompiled Headers. To set this compiler option, follow these steps:
- In the Solution Explorer pane of the project, right-click the project name, and then click Properties.
- In the left pane, click the C/C++ folder.
- Click the Precompiled Headers node.
- In the right pane, click Create/Use Precompiled Header, and then click Not Using Precompiled Headers.
Get rid of this line:
#include "StdAfx.h"
It's not really necessary, unless you absolutely must use precompiled headers. I'm guessing you don't need them.
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?"
You can use something like this to turn the binaries into code, then write them out using the standard library.
If you want to get fancy with the linker, you can also link them to your application directly.
You have:
ptr[M][N] = (double) 1000 + i * N + j;
M
and N
will always be outside of the array, and are the same every time through the loop.
You probably meant:
ptr[i][j] = (double) 1000 + i * N + j;
Same goes for the cout
immediately after.
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.
You are calling a non-const function by a const object. Hence the error. Make the functions as const and you'll get rid of this error.
int statistic::length() const { return amount; }
This is a good practice in general--if your member functions don't change the object, declare them const
.
There seems to be another solution to this. I haven't tried it and I seriously believe it is NOT a reliable solution. Use const_cast on your object before calling those non-const functions.
Yeah, don't do that. There are legitimate uses for const_cast
, but you may live your entire life without needing it.
The way I think it's done is:
- Write the code that displays the GUI ( Window, Button etc ) and put it in functions.
- Give the programmer access to the functions.So, in essence, if I wanted to write a GUI toolkit for the Windows operating system and the ( for simplicity's sake ) C programming language, I could write the assembly code that displays the ( again, simplicity ) empty window, put it in a function, and ( this part I still need to do some research into ) get it to work with C ( as a header file ). Then I just give the file(s) to another C programmer(s) and they just access the functions in the header file, right?
This sounds to me like the 'G' part of "GUI"--the graphical portion. What I don't see there is the 'UI' part--the user interface. The graphics are a fundamental and necessary part, but IMO, a GUI system also should provide standard functionality to work with input devices as well (mouse and keyboard are traditional :)).
Once you have that, there's a design choice to make: Do you provide a full-blown event-driven window management and messaging system, or do you simply provide the toolkit and leave the main loop up to consumers of your GUI system, or something between the two?
Please keep in mind that this is ALL made for simplicity, I actually would like to make it for the LISP language …
http://www.json.org/ has a giant list of libraries. You might look under "C#"; the language doesn't matter as long as it targets the .NET platform.
There are 60 seconds in a minute, and 60 minutes in an hour, so your next step is to start dividing.
Please post any code you've written so far; this will help us help you figure out what you're missing.
I'm afraid that I haven't figured out what's the difference between the actual ISR address and the offset of that address in the interrupt vector table. Let's take the TRAP interrupt vector table address. It is 0024.What does this exactly mean and how is it connected to the ISR address?
You're right; the 8085 jumps straight to 0024h when TRAP happens. But all of the other interrupts live really close as well, so there's not much space to do anything useful there. There is enough space, though, to execute another jump to a much larger chunk of code. I think you're being asked to find the address of that code. Disassemble the bytes at 0024h in your assignment, and I bet you find a JMP instruction.
it's just that I haven't found something relevant to read and understand...
Yeah, there really isn't a lot of useful introductory information about the 8085 out there in the intertubes--mostly it's technical references or super-simplified overviews. :(
I think we need to know what you are trying (inside the try...catch block).
Also would be nice to know how you are connecting to SQL.
Seconded; please post your connection string.
I'm asked which are the ISR addresses of the h/w interrupts TRAP, RST5.5, RST6.5 and of the s/w interrupts RTS5, RST6 and RST7.
I am confused, as I thought that all those interrupts have their addresses, eg. TRAP is always located in 0024, RST5.5 in 002C etc. Could someone please explain to me what I'm supposed to look for, in order to solve the exercise?
I think the exercise is asking you to give the address of the interrupt service routine itself, not the offset of that address in the interrupt vector table. Looks like you know where to find these offsets already, so all you have to do is report the ISR address and you're done. Unless I missed something :)
Please post the error message and the code where the error happens; we can't help if we don't know what's going wrong.
say a variable is declared
extern
in the global namespace. Will it still retain its value throughout all files it's used in?Will it display 10 or will the value of
a
get lost between files?
You still need to include the type of a
in Example1.cpp
, like this:
int a = 10;
If you put a main
function around the code in Example2.cpp
, it should display "10".
You can declare extern int a;
any number of times, but you can only give it a value once, and that will be the value it starts with.
why do we use the "new" keyword?
The new keyword, used this way, is for hiding the base class implementation completely.
See also:
Knowing When to Use Override and New Keywords
Versioning with the Override and New Keywords
Slightly off topic, but related:
Abstract and Sealed Classes and Class Members
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() { }
}
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; …
ok .i figured out how to get textures .. but the image is coming out to be kind of crooked ... as in colorless for some images and kind of dull .. any idea as to why it is happening ??
Might be a problem loading the images. "Before" and "after" pictures would help. Also, this should probably be a new post, since the question has changed.
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.
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?
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.
Please i want to end a program in a function outside
function main.
Is exit what you want?
also want to end executing a function of type void without
allowing it to end
Not sure what "it" is at the end there... if you want to exit a void function, a simple return
statement should do.
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.
i have seen that some amount of the memory like my 8GB pendrive on linux PC which has one unit = 1000 which is exactly same used by the pendrive sellers.....is somewhat less than 8GB.
it is 7.9 GB, why ?
The file system takes up a certain amount of space. It needs to track which areas of the storage device are being used for which files, what the file names are, file attributes, &c. That's probably where the difference is in this case.
also on windows, my 500 GB HDD should be read as 465.66 GB bcz windows take 1 unit=1024 ,,
bt the size is 465.76 GB.. why ?
A gigabyte is traditionally 2^30 = 1,073,741,824 bytes. Storage device manufacturers call it an even billion, so 465.66 GB is correct.
Note that this is roughly 93% of the advertised size. Back in the day when disk drives were sold by the megabyte, it was only 1,000,000 / 1,048,576, or about 95%. The bigger the unit, the worse the marketing lie becomes.
i'm trying to study this paper: http://db.grinnell.edu/sigcse/iticse2007/Program/viewAcceptedProposal.asp?sessionType=paper&sessionNumber=113
it has the 'linearization' in its title. i just want to know what is its meaning. i searched google but it gave me something like calculus which i dont get.
No calculus involved :)
The paper describes a method that analyzes source code, which is not necessarily linear (conditional branches, loops, recursion, &c.). They perform a basic simulation of the program without actually running it, which yields a plausible sequence of actions (i.e., a list, which is linear) that the program might take during normal execution.
Like I said its probably the header or footer information that's added to the exe. This information. header/footer is used by the linker and operating system...
If you really want to see what's in your file then open it in a hexeditor and check the result against the objdump. You'll easy see where the header, footer and your code begins and ends.
It could also be program-specific data that were included at compile time. I believe it's more common for program resources to be stored separately from the executable these days, but this is especially true of older software, which would include fonts, graphics, text, sounds, and whatever else was needed.
Some disassemblers are better than others at automatically identifying bytes as code or data. Even the smart ones get a little confused when certain tricks are used, either intentionally or as a result of compiler optimization. In particular, interesting use of the stack pointer and unusual absolute jumps seem to get missed frequently.
The IBM PC port of Spacewar has some interesting features like this, one of which involves a procedure that displays text from data immediately following the call to the procedure, and resumes execution after the first '\0'
byte--even IDA, which in my experience is a pretty clever disassembler, couldn't figure this one out automatically.
Private Sub Button_Click() Handles Button1.Click, Button2.Click, Button3.Click
MsgBox()
End SubCan anyone tell me how can we print that which button is clicked?????
The Click event is an EventHandler, which takes two parameters, the first of which is the object that caused the event--in this case, it's one of your buttons. Then you can use something like the button's Name property to display which one it is.
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
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.
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.
Also, in the code mentioned above, the ladies wear and menswear arent reachable.. item_code if already 'A' goes to babywear... !! Its either 'A' or 'B'
If item_code is 'A' it goes to baby wear and doesnt even go to else
If item_code is 'B' it goes to if and then first else and then once it encounters item_code as 'B' it goes to childrens wear and doesnt see the else case.. So the last two options are unreachable !
Correct.
There are so many things wrong with this code, I'm just trying to deal with one problem at a time to keep it manageable.
i think giving the file extension is necessary... Eg:babywear.exe or babywear.cpp
What type of file is babywear ??
It's not a file, it's just text. No need for an extension.
which version of c++ is this? I dont think ive come across explanation anywhere... (Thats obviously coz i dont know this).. So, some1 please enlighten me :)
explanation
is a field in the RECORD
struct. It's not being used correctly in the original code that was posted, but we're getting to that.
Well anybody pls try this:
i will give an address that is 0xB8000
Now u write a function in which we can write a string and define its colour so you write the string in that memory area and increment it, and again write the colour info in that area and increment it..
The prototype of function will be
void print_string(int colour, const char *string);remember you write the first letter of string and then increment the address by one and again write the colour and increment the address by one and do that until you write all that string in the memnory area that i gave u. ie 0xB8000
Finally if i write "HI" after writing in memoory it will have
0xB8000 | 0xB80001 | 0xB8002 | 0xB8003
H | colour | I | colour
That's text mode video memory data on IBM PC compatible machines.
Are you asking someone to write the function for you? Post the code you've tried so far, and we can help.
One problem at a time; that is how you fix code.
I copied what you posted and ran it through GCC, which reported several warnings and errors. Before you worry about how to complete the assignment, you need to address these issues, one at a time, starting with the first one reported.
The first one I got was "warning: character constant too long for its type". That's referring to your confusion about single quotes versus double quotes. Go read about constants in C++ if you're still unsure of the difference.
Once you've fixed that, try and compile your code again. If there are still warnings or errors (there will be), post only the first error/warning message you get and a few lines of code around the line where the problem was reported. Then we can look at how to fix that problem.
Although this thread is closed, I feel it needs some additional information:
As far as I know, it isn't possible to create a value type in C#, they are all native to the language.
Structs are value types in C#, and the "simple types" (i.e., the built-in types) are nothing more than aliases to structs like System.Int32. From a developer's perspective, there really isn't much of a difference between these structs and ones you write yourself.
So you want the equivalent of
sbyte myInt8 = 9;
but with a struct? It sounds to me like you want to overload the = operator which is not possible in C# (although you can overload other operators such as +, - and == ).
While you can't actually overload =
in C#, you get the same effect by creating one or more implicit conversion operators.
I'm trying to create a struct for an 8 bit signed integer,
I need information on how to build structs so that they can be assigned values such as:private Int8 Input8Bit = 0;
Using a struct like:
public struct Int8 { }
But I don't even know where to begin. As I stated, any help is appreciated.
If you just need a signed 8-bit data type, try sbyte.
at first, plec correct me this one...
if(item_code=='A') explanation='BABY WEAR';
BABY WEAR and others was error, what should i put?
Chars use single quotes, strings use double quotes:
if(item_code == 'A') explanation = "BABY WEAR";
Hi,
I use an msp430f16 and I want to calculate the execution time of a code (in milliseconds)
any idea?
thanks
It looks like your chip has timers; I don't know the MSP430 series myself, but I bet you could set up an interrupt to keep track of running time. It would be a slight overestimate because of the counting overhead, so it would be more useful for longer-running code.
It is from Chapter 10 of jeff duntemann's book on assembly language. I tried to write some code by myself but I can't get it to work properly. I need some insight please.
I hope I can get some help this time. Last time I post one thread, there was no reply. :(
All I see is some code you copied from a book and a generic plea for help... this isn't going to get you the answers you want. We want to help, but we're not mind readers.
You'll get more responses (and better ones) if you post some code you've written yourself (shorter is better), what you think it should do, what's wrong with how it's currently working, and a specific question or two about what's giving you trouble.
I am making an application like an antivirus, My question is that
I am able to detect the infected hash value, can I delete or remove this infected hash value from this file?
Either you're confused or I am. Would you please elaborate on how you're deriving this "infected hash value"?