|
It would help if you can post the relevant portion of your code.
|
|
|
|
|
here you go:
chapterone:
system("cls");
cout << "Fill in the blank." << endl;
cout << "Loosely defined, a ____ is a group of computers and other devices (such as printers) that are connected by some type of transmission media." << endl;
cout << "A.)Network " " B.)Router " " C.)Switch " " D.)Internet " << endl;
cin >> userinput ;
if (userinput == B,b,C,c,D,d)
cout << "Sorry, that was a wrong answer." << endl;
else
cout << "Congradulations, your answer is correct!" << endl;
system("cls");
cout << "Fill in the blank." << endl;
cout << "Loosely defined, a ____ is a group of computers and other devices (such as printers) that are connected by some type of transmission media." << endl;
cout << "A.)Network " " B.)Router " " C.)Switch " " D.)Internet " << endl;
cin >> userinput ;
|
|
|
|
|
What is the data type of userinput .
rbwest86 wrote: if (userinput == B,b,C,c,D,d)
This statement is wrong.
It should be -
if (userinput == B || userinput == b || userinput == C || userinput == c || userinput == D || userinput == d)
|
|
|
|
|
thank you for helping me with a lot of my syntax problems. I am still learning C++ obviously.
Now another question I have is how to limit the users input to just A-D. If you put in 0 the program buggs out.
So how can I implement more controls in my program?
A separate note is how to make the program progress correctly. If you get it wrong, I need it to count the questions wrong along with the correct questions and display the results at the end. Do I need to associate userinput with correct and wrong strings?
|
|
|
|
|
|
K I just got done reading that power point file you sent me.
Now after reading it I think I need to "flush" the stream?
so I should include a cin.clear() ?
Im a little confused. Because I need to store the amount of correct answers, and the amount of incorrect answers. I will mess with it more in the morning.
|
|
|
|
|
Ok, this is what I have so far:
#include <iostream>
#include <string>
using namespace std;
int main()
{
int userinput;
int inputcounter = -1;
int correctanswer;
int wronganswer;
int choice;
int A,a,B,b,C,c,D,d;
cout << "Roberts Network+ Test Questions" << endl;
cout << endl;
cout << endl;
cout << "Please Select a Chapter:" << endl;
cout << "Chapter One = 1" << endl;
cout << "Chapter Two = 2" << endl;
cout << "Chapter Three = 3" << endl;
cout << "Chapter Four = 4" << endl;
cout << "Chapter Five = 5" << endl;
cout << "Chapter Six = 6" << endl;
cout << "Chapter Seven = 7" << endl;
cout << "Chapter Eight = 8" << endl;
cout << "Chapter Nine = 9" << endl;
cout << "Chapter Ten = 10" << endl;
cout << "Chapter Eleven = 11" << endl;
cout << "Chapter Twelve = 12" << endl;
cout << "Chapter Thirteen = 13" << endl;
cout << "Chapter Fourteen = 14" << endl;
cout << "Chapter Fifteen = 15" << endl;
cout << endl;
cin >> choice;
switch (choice)
{
case 1: goto chapterone;
break;
case 2: goto chaptertwo;
break;
case 3: goto chapterthree;
break;
case 4: goto chapterfour;
break;
case 5: goto chapterfive;
break;
case 6: goto chaptersix;
break;
case 7: goto chapterseven;
break;
case 8: goto chaptereight;
break;
case 9: goto chapternine;
break;
case 10: goto chapterten;
break;
case 11: goto chaptereleven;
break;
case 12: goto chaptertwelve;
break;
case 13: goto chapterthirteen;
break;
case 14: goto chapterfourteen;
break;
case 15: goto chapterfifteen;
break;
default: cout << "Error, invalid entry." << endl;
}
while (inputcounter <= 20)
{
chapterone:
system("cls");
cout << "Fill in the blank." << endl;
cout << "Loosely defined, a ____ is a group of computers and other devices (such as printers) that are connected by some type of transmission media." << endl;
cout << "A.)Network " " B.)Router " " C.)Switch " " D.)Internet " << endl;
cin >> userinput, inputcounter ;
++inputcounter ;
if (userinput == B || userinput == b || userinput == C || userinput == c || userinput == D || userinput == d)
{
cout << "Sorry, that was a wrong answer." << endl;
++wronganswer ;
}
else
{
cout << "Congradulations, your answer is correct!" << endl;
++correctanswer ;
}
system("cls");
cout << "Fill in the blank." << endl;
cout << "Loosely defined, a ____ is a group of computers and other devices (such as printers) that are connected by some type of transmission media." << endl;
cout << "A.)Network " " B.)Router " " C.)Switch " " D.)Internet " << endl;
cin >> userinput, inputcounter ;
++inputcounter ;
if (userinput == B || userinput == b || userinput == C || userinput == c || userinput == D || userinput == d)
{
cout << "Sorry, that was a wrong answer." << endl;
++wronganswer ;
}
else
{
cout << "Congradulations, your answer is correct!" << endl;
++correctanswer ;
}
system("cls");
}
chaptertwo:
chapterthree:
chapterfour:
chapterfive:
chaptersix:
chapterseven:
chaptereight:
chapternine:
chapterten:
chaptereleven:
chaptertwelve:
chapterthirteen:
chapterfourteen:
chapterfifteen:
cout << "Your score is " << (correctanswer - wronganswer);
return 0;
}
So after reading my source, what are some of the multiple problems I have so far? Please keep in mind that I am trying my hardest to make sense of things and looking online for every possible resource I can.
Thank you in advance.
V/R
Rob
|
|
|
|
|
I am working on a ISAPI filter. I need some information that user entered on a web page. I tried to process SF_NOTIFY_PREPROC_HEADERS, SF_NOTIFY_READ_RAW_DATA and SF_NOTIFY_URL_MAP events, and was only able to get the full header.
How can I get the whole contents of the request, including form, fields and their values?
I'll very much appreciate your help.
Jack
|
|
|
|
|
I'm trying to convert some old code that is using 'calloc' to use 'new' but I'm having a little trouble with this:
void (**temp_stack)(void);
temp_stack=(void (**)())calloc(count+1,sizeof(void *));
I tried using this:
void (**temp_stack)(void);
temp_stack=new (void*[count+1]);
but get the following error:
error C2440: '=' : cannot convert from 'void ** ' to 'void (__cdecl ** )(void)'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Can anyone help me figure it out?
Thanks,
George
George
|
|
|
|
|
void (**temp_stack)(void);
temp_stack=(void (**)())calloc(count+1,sizeof(void *));
that doesn't even compile in VC6.
|
|
|
|
|
Chris Losinger wrote: that doesn't even compile in VC6.
It does in VC2010. What is the error message you got?
|
|
|
|
|
error C2563: mismatch in formal parameter list
|
|
|
|
|
This should work:
typedef void(* void_pp_fn)(void);
void_pp_fn* temp_stack=new void_pp_fn[count+1];
|
|
|
|
|
I am attempting to perform the following, where I know that T is an integer type of some sort:
template<typename T>
inline T foo(const T a, const unsigned T b) {
...
} However, I am getting a C2146 error that reads, "syntax error : missing ',' before identifier 'b'". For some reason, the compiler doesn't like "unsigned T", so I tried "typename unsigned T" and "unsigned typename T" as well to no avail. Is there some way to make this compile without resorting to something like the following:
template<> struct get_unsigned<long> { public: typedef unsigned long type; };
template<> struct get_unsigned<int > { public: typedef unsigned int type; };
template<> struct get_unsigned<byte> { public: typedef unsigned byte type; };
...
template<typename T>
inline T foo(const T a, const typename get_unsigned<T>::type b) {
...
} Thanks,
Sounds like somebody's got a case of the Mondays
-Jeff
modified on Wednesday, January 27, 2010 4:38 PM
|
|
|
|
|
I think the answer is that you can't use "unsigned" by itself.
What if someone were to try to create an instance of your class of type "unsigned FooBar"?
That wouldn't make any sense, would it?
|
|
|
|
|
That's a never ending discussion that happened inside the standardization commetee.
Your appoint appears correct but is in contrast with SFINAE (Substitution Failure Is Not An Error), that requires errors to be notified only at instantiation.
Otherwise expression like a+b will be subjected to your cnsideration if a and b ar FooBar -s and there is no operator+ for FooBar .
But we all can write
template<class A>
A add(const A& a, const A& b) { return a+b; }
and get errors only upon attempting an instantiation of A with no operator+ available.
The point, here is that the standard does not consider the word unsigned as an adjective to something, but defines "unsigned int" , as well as "unsigned long" etc. as type names themselves.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
No, that wouldn't make sense, but it also wouldn't compile. I was under the impression that templates are compiled on a per template-parameter basis... ie, for each distinct set of template parameters, there exists independent assembly at distinct memory addresses. I interpret this as meaning, "As long as a template is syntactically correct, it will be compiled once for each distinct set of template parameters". Therefore, I would expect someone who called my code with class "FooBar" as the template parameter to get an error notifying him/her of an unknown or invalid type, whereas someone compiling with int would work just fine.
As an aside, just because a piece of C++ code can be used in a way that doesn't make sense doesn't mean it is invalid code. The compiler doesn't complain at all if I call numeric_limits<FooBar>::digits, which clearly also doesn't make sense. Sometimes when performing design by contract, verifying that the user abides by the contract is far too expensive to be practical. Most C++ code cannot be written to be idiot-proof.
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
what compiler was used compile a classes in c++
if any subract compiler for classes is there... if there means what about c++ compiler done.....
Best Regard's
Mathy's
|
|
|
|
|
|
Depends on what platform you are targeting and what platform you are using to develop your programs. Please offer more details on these.
|
|
|
|
|
using only windows platform.....
if am using classes in C programming.... how to compile a classes in C compiler. Its possiable.
Best Regard's
Mathy's
|
|
|
|
|
C++ compilers are a lot more complicated than C compilers. I am not aware of a C compiler that can compile C++ classes. Why don't you use a C++ compiler? Other replies to your post already gave you suggestions on which compilers you can use to do that.
|
|
|
|
|
All C++ compilers compile (syntactly correct) classes.
As it stands your question make no sense to me.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Could someone knowledgeable about usage of DLL in VC 6.0 give me a hand. I need a short description about the organization of the files in the project.
I checked this site and found some helpful articles but I am still not sure about how to do this.
I am doing a main project with dependent DLL.
The wizard created a DLL with samples, however, I am confused how to integrate this to the main project.
I have a basic understanding about this macro __declspec(dllexport).
However , there are lib and linker "options" __declspec(lib, "xx.lib") and __declspec(link, "xx.lib") which I do not understand.
These options accomplish the same as VC Project Options, right?
Also, the #include "library.h" is now in debug directory. I assume that I need a #ifdebug directive somewhere to keep the reference correct in release.
Do I still need to register the DLL with windows (regsvr32) ??
Thanks for reading. Appreciate your help.
Cheers Vaclav
This is VC 6.0 DLL wizard generated stuff
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the OPENHRLIB_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// OPENHRLIB_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
#ifdef OPENHRLIB_EXPORTS
#define OPENHRLIB_API __declspec(dllexport)
#else
#define OPENHRLIB_API __declspec(dllimport)
#endif
|
|
|
|
|
Well, that is rather a lot of questions to answer, however, I'll try.
Vaclav_Sal wrote: I have a basic understanding about this macro __declspec(dllexport).
Knowledge of this is less important than understanding how a library (lib or dll) is linked to an executable. If you read the MSDN literature it should make this clearer.
Vaclav_Sal wrote: However , there are lib and linker "options" __declspec(lib, "xx.lib") and __declspec(link, "xx.lib") which I do not understand.
The lib processor collects a set of object modules and builds a static (lib) or dynamic (dll) library. Generaly speaking Visual Studio or VC will set the correct options when you create the project. The linker options should be set when you select the lib file into your linker settings in the project options.
Vaclav_Sal wrote: Also, the #include "library.h" is now in debug directory. I assume that I need a #ifdebug directive somewhere to keep the reference correct in release.
I'm not sure what you mean here, but I presume that this include should be added to your project whether debug or not, so you probably do not need any #ifdef .
Vaclav_Sal wrote: Do I still need to register the DLL with windows (regsvr32) ?
I'm not sure about this, I just copy the dll to the Windows/System32 directory and my apps tend to work fine.
MVP 2010 - are they mad?
|
|
|
|