6+2x10 is easy
but
I oftened wondered what 7+2x10 could be
You're kidding -- right ??? (27)
6+2x10 is easy
but
I oftened wondered what 7+2x10 could be
You're kidding -- right ??? (27)
Today is a national holiday in USA (Memorial Day), and most people have a barbecue. We cooked hamburgers, brots, pork ribs, pork chops. Also made cole slaw and potato salad. There was enough food to feed an army, so I don't think anyone will ge cooking at my house for awhile.
And of course, since I'm retired US military, I have lots of US flags flying around my home in honor of the many brave men and women who gave their lives for my freedom.
So the program converts the character into a number, as variables a & b are of int type and not char.
However, it should convert the character into its ASCII code, but I don't know why does it give such an odd output.
It does no such thing. cin produces an error and does nothing at all, leaving the value of the integer unchanged. The value that was shown in the output was just some random value that was in that memory location when main() was entered from the program's startup code -- which is the code that the compiler adds to the program and is executed before main().
You can easily verify this yourself by initializing the variables when they are declared, such as int a = 1, b = 2;
My wife made a bananna nut cake yesterday.
Nice reply to 3-year-old thread. I suspect the OP already knows that by now.
It must be lonely being an atheist. Believing there is nothing after death makes life meaningless.
I meant the "dope smoking hippie" part.
A Dope smoking hippy up in the hills wrote the bible.
Do you speak from experience :)
What you are saying I hear alot. Give me a contradiction and I will investigate. Can you please give me verses that you find disturbing?
Biblical contradictions link here
But that doesn't mean the Bible is a fairy tail. It was written by many people over several centuries, so there are very likely to be contrictions. Genesis was written some 5500 years ago from a collection of documents gathered into the book of Genesis by Moses. Link.
And I agree that some of the Bible (e.g. creation) is meant to be taken metaphorically. Yes, God created the universe and everything in it, but the Bible doesn't explain how it was done. We now know that the universe was created over many billions of years and life on Earth evolved. Do you really think people at that time could have comprehended the idea of evolution of huge time spans like billions of years? Those people thought the Earth was the center of the universe and that it was flat. God spoke to those people in terms that they could understand, even though it was much too simplistic.
No one will write your program for you. Just don't get overwhelmed with all the requirements. Do it a little bit at a time and you will be able to write it yourself. For example, start out by creating a program that does nothing more than display the menu. When you get that coded, compiled and working correctly you should code a function that implements each of the menu items, but only code, compile and test one function at a time. When done just a little bit at a time you will find the program is much easier to write than you feared.
Best of luck :)
6+2x10 is nonsense
6+2*10 is 26
Yes, it would be if it were written in C or C++ (and several other computer languages). But this is a math quiz, not a programming quiz. I don't recall ever seeing * meaning multiply until I started learning programming.
Really, in 80s?? I thought It was already widely used then. When was it invented 60s or 70s?
The first ansi standard for C language was not officially ratified until 1989. I used Lattice C compiler in those days and they were unable to make it ansi compliant so they lost their entire c compiler business. Their compiler was so buggy that it was unusable. That's when we switched to Microsoft C compiler.
I'm using 64-bit Windows 7 and have not had any problems with it. What are you trying to run that doesn't work?
use strtod() instead of atof(). Read the description of that function carefully and you will see how you can use it to verify that the string contains only numeric digits plus dot and dash. Otherwise you can just parse the string yourself to validate it.
that's true -- atof("2a") is 2.00. I have no idea what the 'a' is for, but atof() stops converting at the first character that is not a digit or '.' or '-'.
When is the assignment due, that is, how much time do you have before you have to turn it in? Have you studied c++ classes and arrays yet?
Once text files are written you can not overwrite the data with larger amounts because it will overwrite other data that follows it. For example if the file contains "Hello world" and you want to change it to "Hello12 world" the result would be "Hello12orld", which ic clearly not what you want.
There are a couple ways to resolve the problem
(1) If the file is small, read the entire file into memory, make in-memory changes, then rewrite it back out.
(2) For large files you will want to use a temporary file, reading from original file and writing back to new temp file. When done, delete the original file and rename the temp file to the name of the original file.
BTW: The code you posted is not compilable.
In USA any 5th grade student should have known the correct answer. And Shame on anyone who is a programmer and doesn't know it.
C programming in mid-80s -- zenith 100 computer, 2 floppy drives, no hard drive, 64K 8 MZ RAM, MS-DOS Version 1.0 which did not support sub-directories. The C compiler was on a 5 1/2" floppy in one drive and the data/program in the other drive. Started a compile then go read a book or something, come back in about 1/2 hour and it might be done.
C language was still in its infancy, no function prototypes, which made for very buggy programs.
Programming in 60s: No personal computers, all programs were written in binary and hard-wired the circuits. Glad I wasn't writing programs in those days :)
26. Not much thought needed. 6+2x10 = 6+(2x10) = 26
What version of Turbo C++? If its a 16-bit compiler then probably not.
in a loop check each character of the string to see if it's a digit or an operator. If its a digit then add to a vector of integers, otherwise if it's an operator add it to a std::string of operators.
Since this is probably homework, I'm not going to post the complete solution. You have to write it yourself and post what you have done.
My I live under the rule for almost 13 years, been told that Russia is the best and be great full for what we have to Lenin and Stalin.
The best at what? Best communist country? Might be, I don't know. But I hear people in Russia have very limited food in their stores with long lines to buy anything. That's what I hear from here.
>>Could you please explain how this can be when the gap between the rich and poor continues to expand rapidly in the USA
Yes, I can explain it in just one word -- Obamacare. I didn't say USA is becoming a perfect socialist nation, just heading in that direction, and have been since 1965 with President Lyndon Johnson's "Great Society" program, which is nothing more than redistribution of wealth. And Obamacare will be much the same because it will eventually cost the tax payers trillions of dollars.
You need to get input as std::string then pars it to extract the integers and operators. Since they can be entered in any order there really is no other way to do it.
Any Advice/Idea!
If you expect the answer you want then you have to learn how to ask the correct question. I answered the question you asked, nothing more :)
>>is it possible?
Yes.
The error message tells you what you have to do
error C2440: 'initializing' : cannot convert from 'b_t **' to 'a_t *const *'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast a_t* const * ref_pa = reinterpret_cast<a_t**>(&pb);
I really disagree with you Ancient Dragon. They are not always run by tyrant. You are only talking about Soviet Union
Really?? I would classify the dictatorship in China in the same category, although AFAIK China is not really communist anymore either because it has been evolving into a capatilist country for several years now. In the same light, USA is not a democracy (or federalist) country any more either -- its evolving into socialism.
What you are describing is socialism, not communism. Communism asserts that the state owns everything, no private person can own anything, and that goods and services distributed among the people according to need. Also communism does not allow free elections, or free anything else either, such as religion. Communist coutries are run by tyrant dictators.
If your country were to suddenly come under communist control, everyone would immediately be tossed into the poor house. People with lots of education most likely would be shot (executed). Is that the kid of life you have in mind???
I doubt such a thing would happen in USA because we are too well-armed and would kill anyone who attempted it.
You mean you wrote a program with 64-bit compiler and tried to run it on a machine that is 32-bit operting system? That won't work. Compile it with 32-bit compiler and it will work on either 32-bit or 64-bit machines.
Next, you have to probably install the MFC re-distributables. Look in your compiler's install directory and you will probably find them. If not, then look on the DVD that the compiler was on. If all else fails, you can download them from here
The program you posted is still wrong. The answer would be undefined because p[3] = the letter 'E' and p[1] is the letter 'A'. so p+'E'+'A' = p+69+65, or 127 bytes beyond the end of the buffer. Where did I get those numbers? From any ascii chart, like this one.
I had a cat, but personally, i find that people have animals because they can't find "love" within their own species..
You are 100% wrong.
You mean you want to listen to music while using VS? You don't need a plugin for that.
The death penalty??? I'd rather they just chop off a limb, such as a finger or a leg. Eventually the pirate won't have any fingers left to use the internet :) But the death penalty is too extreme.
Nice -- bumping a 5-year-old thread with no new content.
line 11. There's the easy way to code it. Notice it does not do any seeks() or memory allocations because std::string will do all memory allocations for you.
// Player's Name
std::string name;
ifstream CharName("C:\\ZacarasEmpire-Offline\\Data\\File01.ze");
if( CharName.is_open())
{
CharName >> name;
CharName.close();
cout << name;
hEditName = CreateWindow(TEXT("STATIC"), name.c_str(),
WS_CHILD | WS_VISIBLE | SS_LEFT,
40, 190, 100, 23,
hWnd, (HMENU) IDC_EDIT_NAME, GetModuleHandle(NULL), NULL);
}
Again, the character buffer is not null-terminated. Why not just do CharName >> NameBuffer;
or CharName.getline(NameBuffer,NameLength);
Better will, declare NameBuffer as std::string instead of char*
ReadFile() does not null-terminate strings -- it treats the file as if it were a binary file. Instead of CreteFile() and ReadFile() why don't you just use standard C++ fstreams. Just because you are writing a win32 api GUI program doesn't mean you can't use c++ fstream or other STL containers.
>>line 7: int NameSize = sizeof(hFile);
Huh? That will not give you the size of the strName(), or even the size of the file.
I see you never used pirate websites. I do not support piracy but I think current copyright laws are outrageous. If they do not change them there will be more and more piracy. I have about 8 friends in school who download pirate music and only 1 who actually pays for it! I think it is not fair and wrong. If you will just keep closing web-sites like piratebay more will pop-up and nothing will happen. What is needed is a major copyright reform.
So you don't think theft is wrong. Please give me your home address so that I can come over and steal everything you or your parents own. No matter how you want to justify it, theft is theft. Artists and record/music/movie companies work hard to create the stuff you like and you have no right to steal it from them.
There is not a thing wrong with our copyright laws.
It would not surprise me if many pirated programs contain viruses and malware. That's another good reason not to download and install them.
Please post the entire code that will actually compile. That means adding all the parentheses, commas and semicolons, as well as the function.
What everyone else is getting is probably illegal, so be careful that you don't get sued for downloading copright material.
call CreateThread() or _beginthread() in WM_CREATE, not WM_PAINT.
Creating a console from GUI is simple -- just call AllocConsole(); Example
void ConsoleThread(void* p)
{
HANDLE hStdin = 0;
HANDLE hStdout = 0;
DWORD dwCharactersWritten = 0;
if( AllocConsole() == 0)
{
return;
}
HWND hConsoleWnd = GetConsoleWindow();
hStdin = GetStdHandle(STD_INPUT_HANDLE);
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
while(1)
{
WriteConsole(hStdout,"Hello\n",6,&dwCharactersWritten,0);
Sleep(2000);
}
}
You can read the characters that are on the console windows by calling win32 api functgion ReadConsoleOutput()
DaniWeb has server problems occasionally and sometimes I have a problem now and then like you mentioned (maybe only about once or twice in any given week). It might be that you are trying to make a post at the moment their servers go bonkers. But since you were able to post this thread I assume the server was working ok for you at the moment.
>>Don't #include C header files in your header files
That's one of YOUR rules that is frequently broken. I agree with the general pholosophy, but it doesn't really work that way in real-world programs and libraries.
Since you don't know how to use pointers you might want to read this tutorial by DaWei, member at PFO
That is the correct way to access the members, but you have to allocate memory for all those pointers. For example
fat *pfat = new fat;
pfat->dir_array = new dir;
pfat->file_array = new files;
Also, what do you want to store in the name member functions? If its supposed to hold a filename then you need to make more room for them because file names can be up to 225 characters!
Because its in the ISO standard, so compiler writers have little choice. Also, if they removed the function then it would break all legacy code that used it.
If you want to read words instead of lines call fscanf() instead of fgets(). But with fscanf() the program can not distinguish end-of-line. If it needs to know about EOL and also read words then you will want to call fgets() and parse the string into words. strtok() can be useful for that, assuming you don't mind that strtok() will put NULL bytes in the string where the tokens (spaces) appear.
>>and the printf returns null
The return value of printf() is normally ignored. If printf() fails it will return a negative value, not null.