I have an assignment to create a program that will display the duplicate numbers that were entered by a user. I have the code finished and I have covered the basic requirements of the assignment. However, during my testing I found that if I enter anything other than a whole number (i.e. char or float) the program will run out and exit. I would like to add a little code to verify that the user has entered a whole number. I cannot seem to get this to work though. I have written other codes that verify if a number is above and below a certain value, I just do not know how to look for a certain type of entry.Here is my code:
int main() {
int number[20];
int duplicateNumber[20];
int i, j, k, counter = 0;
// Get number input from the user
for (i = 0; i < 20; i++) {
printf("Please enter a whole number %d: ", (i + 1));
this is really important i searched an example code about "Username and Password Validation between Server and Client" through internet a LOT and i couldn't find anything..
I am trying to build a program that takes a user password (6+ characters, One uppercase, one lower case, and one number), and checks for errors. The idea is that if the user is doing something wrong (say, forgetting to use an uppercase letter), the program will tell them what the error is, and prompt them to enter the program again.
I get through the building process without errors, but whenever I run the program, I get this error: [URL] ....
Here is my code:
#include <iostream> #include <cctype> using namespace std; bool checkPass(char [], int); //Password Checking Function char convert(string);
[Code] ....
According to the box, the error appears on line 56 and 68.
I tried to build a basic username-password verification program; I already have 2 text documents, usr.txt and pass.txt in which username and password are stored. Then have written this program to check the username and password, but every time it says Access Denied.
I have the following code in sourceFile.cpp. functionA() is first called and inserted entires for key1, key2 and key3. Then functionB() gets called to use the vectors for the 3 keys. I want to free all memory after exiting functionC(). Among the three ways to put an entry into the map for the 3 keys, which is correct / better?
Class ClassA { ... } ClassA *key1 = new ClassA(); ClassA *key2 = new ClassA(); ClassA *key3 = new ClassA();
We've been tasked write a code which would mimic a secure entry keypad.. Only recognising the digits 0-9 for the passcode, and non-numerics S (start again) C (clear last digit) and E (enter) for the control. All other key strokes are to be ignored.
The passcode has to be <10 digits and represented on the screen by "****", with any keystrokes >10 ignored. The valid passcode being 4 digits (1234).
With 3 attempts to get the correct pass code, after each fail attempt as please try again message show, where after the 3rd attempt a specific message is displayed and an alarm sounds..
Still working on my first homegrown C program design . The function basically allows the user to enter a list of classes and grades and saves the list to a file to be used later in the file. The function compiles and runs through without error except for the fact that it always prints the last user entry to the *profilep file twice. Just as a note, the scanchar function is one I made to scan in one character and an end of line character to throw away the end of line char before I learned about %*c about 30 minutes ago...
Also I haven't much bothered to strengthen the function against crazy user input but I have heard using fgets and sscanf in conjunction can replace scanf and protect against weird user input. How to apply this within the program.
Code: // creates a new profile and prints it to the profile file. void newprof(FILE* profilep, const char *allclasses[ABBR_SIZE]){ int c, checker, counter; int i, a; char prof[MAX_PROF][ABBR_SIZE]; char grades[MAX_PROF][3];
Using VC++ 2010 Express. I am creating a dll to export a simple Multiply function so I can use it in Excel/VBA
These e are the steps I am following :
. Create a Win32 C++ Project and give a name. For example: CallDllFromVBA . Select the DLL option in the Wizard and click Finish . In the CPP file (here CallDllFromVBA.cpp), add the following code
#include "stdafx.h" int _stdcall Multiply(int x, int y) { return x * y;
[Code] ....
The Build output show everything is ok as follows :
CallDllFromVBA.cpp CallDllFromVBA.vcxproj -> c:documents and settingsadministrateurmes documentsvisual studio 2010ProjectsCallDllFromVBADebugCallDllFromVBA.dll ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
In VBA, I insert a module and add the following code:
Declare Function Multiply Lib _ "c:documents and settingsadministrateurmes documentsvisual studio 2010ProjectsCallDllFromVBADebugCallDllFromVBA.dll" _ (ByVal x As Long, ByVal y As Long) As Long Sub test() MsgBox Multiply(2, 4) End Sub
When I run the Test sub I get the error: 453 - Can't find dll entry point
I also opened the CallDllFromVBA dll with Dependency walker and I can't find the Multiply export function - In fact, the dependency walker doesn't show any function exports at all for the CallDllFromVBA dll !
I'm playing with my final year project, building a game boy emulator in C, and I wanted to try out something to streamline my code base. I'm building against Win32, GNU C and Googles Native Client.There are no platform specific headers or functions in use. What I'm trying to do is have a file that conditionally includes the entry point (so _tmain for Windows etc) based on a preprocessor directive being set/not-set.
[note] I realise I could write both entry point classes in one file and use the preprocessor directive in there, but it's not as neat as a single file calling in one or the other. I figure this should work because I can conditionally include headers for Win/NaCl (providing the signatures match, of course).
I'm having an issue during the linking stage of the .exe during compile time, and it's because of a call to a function with a polymorphic parameter.
//here's how the classes are setup class grandpa {}; class mom public grandpa{}; class dad public grandpa {};
[Code]....
dad has sons in the vector and mom has daughter in the vector. What I want to do is have a function that can accept either of these vectors as one parameter like so: void func(const grandpa* aObject);
Finally, I have an error when I pass an object to the function like so: func( d[0] );
I'm learning C# and having fun and I've been practicing by working on this little data entry console application. Basically the user inputs first name, last name, age, gender, employee id, then I ask the user if he/she wants to add another entry, if yes then loops back at the top, and if no, it prints out the amount of entries added. The issue I'm having is that the entry list is never kept or stored when adding another entry, it replaces what was entered before which is not what I'm looking for. I don't know how to stuff one entry list information seperately in an array so that I can print out which ever entry the user decides to choose once he/she is done adding entries. Is there a way to make this work?
Here is my program code:
using System; namespace Ch02_Exercises_12 { class Program { static void Main() { string firstName; string lastName; string input; sbyte age; char gender;
I created program that insert employes data and then print their data but never accept duplicate age if user entered duplicated age prompt him to enter another age (age must be unique)
Here is my code
#include<conio.h> #include<stdio.h> #define size 3 struct emp { int age,overtime,dedcution,netsal;
I am stuck in visual studio 2010 file I/O ... i placed file1 file2 using the following program under VS2010/projects/projectname/file, file1 and also in debug also once......I am actually using cmd line arguments in debug mode
Code: // feof files.cpp : Defines the entry point for the console application. //
#include "stdafx.h" #include<stdio.h> #include<stdlib.h> #include<conio.h> int main(int argc, char* argv[])
[Code] ....
I dont think in C++ forum the printf will do any problem...when i run the program it says "cannot open source file" and a window appears saying"Debug assertion failed"....and other details such as Expressionstream!=NULL).perror
I hope that this isn't an elementary question to you more experienced people, but I am having some trouble with my .DLL file. I haven't ever had a problem with compiling and linking it with my main project before, but it appears now some sort of problem has started. The message that appears is :
I have no qualms with posting my .DLL source, as it is not particularly long or complex. It seems the problem functions are the last two I've added ( load_sound( ) and play_sound( ) ).
Here is what I'm linking it with :
Code:
-------------- Build: Debug in game (compiler: GNU GCC Compiler)--------------- mingw32-g++.exe -shared -Wl,--output-def=binDebuglibgame.def -Wl,--out-implib=binDebuglibgame.a -Wl,--dll -L"F:FBLARandom gamegame.dll.sourcegame" objDebugconversion.o objDebugprojectile.o objDebugSDL_utility_functions.o objDebug ime.o -o binDebuglibgame.dll -lSDL -lSDL_mixer Creating library file: binDebuglibgame.a
Output size is 49.10 KB Process terminated with status 0 (0 minutes, 0 seconds) 0 errors, 0 warnings (0 minutes, 0 seconds) projectile.c :
I have a program including several code blocks in the following simplified structure:
int main() { // block A if(a > 0) { }
// block B if(a > 1) { } }
Block A and B should be executed separately, according to entry from keyboard. For example, if entry "1", block A will be executed and block B will be ignored; if entry "2" the inverse will happen.
I can control the execution of these two blocks through macro but the code will be separated during compilation. But is there a way to control them without using macro?
When I am filling a Application form and save this Application form Entries in database it saved successfully but below Application form in DataGridView How to show only current Entry row; There is not show a previous Entries in DataGridView?
I am supposed to write a simple voting program as a semestral project. There are about 30 people in our class and we are going to compete with our voting bots against each other (+ some random traffic bots). The principle is simple - every 50th entry (vote) wins.
We are given the results website, where we can see winners and current vote count. Nothing more. Oh, and everybody has only 50 votes (except traffic bots).
I have already written voting function, function to extract the number of votes from the results website, function to find out server response time and made some voting bots to simulate traffic on the server (voting every 2s, 4s,..., randomly). But now I got stuck with the algorithm which should decide, when to vote.
I guess that most people in my class are going to use something like "if there are more than 45 votes and less than 50 -> vote" approach.
I was thinking about measuring average latency and average traffic for first few rounds but there are going to be many 'outliers' just before the 50th votes and based on my bots, the latency is going to drop rapidly (my 2s bot voted 10s late because the server couldn't handle the load). I just don't see the connection between vote count and server response and how to measure the right voting moment accurately.
OK I'm making a simple program to make a shopping list. I would like the program at start up to load the previous shopping list that was saved as a text file. The format is one line per entry which consists of the category or Isle, and the item description. Here's an example:
3 Dog Food Produce Sweet Onions
I reading the first word, and then I want to read the rest of the line which may have more than one word... the problem is my code hangs... or goes into the old infinite loop. It doesn't see the end of file.
Here is my code:
void addItemsFromFile(vector<item> &shoppingListVector) { string word; char buf[30]; if (fileExists("shoppinglist.txt"))