1. In main() in the while loop entering 'q' does not exit.
2. in the isbnValidation function. The size check for minimum length words will work, but the check for "Invalid ISBN character" doesn't.
3. Every ISBN entered returns as valid. The formula is supposed to multiply the first digit by 10, next by 9 etc (skipping all the dashes) and add up to a weighted total which if valid will divide evenly by 11.
I had the entire validation working until my professor said that my Pop function had to be a "void" not a "Char". Which destroyed my previous validation and now how to validate this.
I will only be posting the validating function.
All the characters are being thrown in a Stack. So I am using Pop/Top/Push/isEmpty/isFull. That will be shown in my validating code.
Correct Validations: 1. {}()[] 2. [()] 3. {([])}
Incorrect Validations: 1.[) 2.[(]] 3.{])
My main issue is that it validates "[)" correct.
I am pretty positive I must have over complicated my validation.
I am working on a program where the person enters their name and their gross pay. I had to validate that the gross was a number and contained no letters.
I also have to validate the persons name to see if it contains any numbers. The book I am using has an example with only an if statement that says if it is correct or incorrect. I was trying to use <cctype> and toalpha
I just was wondering if there was a way to put it into a while loop or how i would have it ask the user to input their name again. When i tried it just blew up.
Also in the book they use const int SIZE= 8, but I don't want to put a size on the name if I don't have to.
i have a code which compares between these two variables. date1 and date2. The program runs when the user input two correct dates eg: 20/10/2003 20/14/2004 then it will read and display values in between the date. That means if the user enters other characters like alphabets or other weird characters the program will prompt an error and not run.
Only with the correct input(int) then it can run. how can i implement this in that case? probably in real expressions or switch case? This is my code:
/* * date_compare compares two dates, returning <0, 0, >0 if * date1<date2, date1==date2, date1>date2, respectively */ int date_compare(Date *date1, Date *date2) { if(date1->year < date2->year) { //printf("Year is smaller");
Question simple like that: Let user enter some words from keyboard, one word per line until a '.' (period) entered then print out result, for example:
Code: Enter a word: word1 Enter a word: word2 Enter a word: . You have entered 2 word(s): word1 word2
Problem is I don't know how to declare the array of character at the beginning since I don't know neither how many word user may enter nor how many letter of each word. So I go ahead and declared like this: char word[20][50] but I know it is not best way.
Code:
int main () { char word[20][50]; //array has maximum 20 words, each word maximum 50 character int i=0, number_of_word; do { printf ("Enter a word: ");
I am unable to get the string seaching function to work. it always says "Nothing found" I am stumped.
Code:
#include <stdio.h> #include <string.h> char tracks[][80] = { "I left my Heart at Harvard Medical School", "Newark, Newark, You suck balls", "Dancing with a dork", "From Here to maternity", "The Girl from Iwo Jima",
Lexer.cpp: In member function 'void Lexer::PrintSource()': Lexer.cpp:29:42: error: 'struct std::pair<const std::basic_string<char>, std::vector<std::basic_string<char> > >' has no member named 'begin' for(auto SubIterator = Iterator->begin(); SubIterator != Iterator->end(); SubIterator++) ^ Lexer.cpp:29:76: error: 'struct std::pair<const std::basic_string<char>, std::vector<std::basic_string<char> > >' has no member named 'end' for(auto SubIterator = Iterator->begin(); SubIterator != Iterator->end(); SubIterator++) ^
If I were to exit a program, is it okay if I fail to properly destroy whatever structures were allocated?
For instance, if I do this with SDL, there might be obvious consequences like a dead window perhaps. But if I do this with a POD structure, is it okay?
Also, I realize RAII is supposed to fix parts of this but it's not perfect when environments are suddenly cut off with something like exit(1/0);
I'm parsing an xml file full of payslips and using the data in another application. I've got it all working but I suspect it isn't the most elegant piece of code. I run through the xml file finding a series of "Text" attributes/elements" and then I run through it again finding a series of "Field" attributes/elements, Here is a sample of the code:
// // Get all the Text attributes & Elements // foreach (XElement xtxt in xdoc.Descendants(ns + "Text"))
[Code]...
This works fine, I extract all the data I'm interested in and go to do my thing with it. However I really need to know when each record ends and I was doing that by looking for "Text24" in the text fields and "EeRef2" in the field fields, which wasn't very elegant in the first place. Then a "Text16" was added to end of each record which was fine I could just look for "Text16" but now it's apparent that "Text16" isn't always there. I've got it all working for now but I'd prefer to process one record at a time i.e. extract all the "Text" & "Field" values for one record, do whatever I need to do with it, update the xml file to indicate this progress ( if possible ) and then move on to the next record. I've attached a sample of the xml but basically is has the following structure :
I'm using MS' optimizing compiler CL 13.10 (one from VCToolkit 2003) along with WinAPI threading functions and is being compiled as a C console program.
I was wondering how to implement threading in a production setting? I've seen and tried various examples, but they all show basically the same thing - startup in main, run their function, clean up, and then the program exits.
I don't know the proper terminology, but I was looking for two maybe three functions to run simultaneously with a loop in main. I tried a small test program and was wondering if it's setup correctly.
A structure is used as the argument for each function.
int running = 1; // global variable DWORD WINAPI function_1(LPVOID); DWORD WINAPI function_2(LPVOID); main() { HANDLE hndThreads[2]; DWORD threadIDs[2];
[code].....
Right now, function_2 is just a copy of function_1's definition. Everything *appears* to do what I want, but is it setup correctly?
i am facing some problem with qsort() function it work well if the last element of array is larger then the 2nd last element. But in case if last element of array is smaller then the 2nd last it will sort the whole array and remains the last as it is. For example
Code: int group_id_local[max_j]={2,1,4,5};// it work fine, output should be {1,2,4,5} but if i have this one
int group_id_local[max_j]={2,1,4,3}; // output should be {1,2,4,3} /* COMPARE FUNCTION FOR USING QSORT()*/ int cmpfunc (const void* a, const void* b) { if (*(int *)a < *(int *)b) return -1; if (*(int *)a > *(int *)b) return 1; return 0;
I'm trying to fill the array "g" with letters from the array "letras" given a certain condition. Everything is working fine, except I couldn't do it... Strange characters appear when I run the code. What am i doing wrong?
Note: This is a part of a function. "vetor" is a parameter that was passed to this function.
Code:
int i; int j = 0; char g[20]; char letras[5] = {'a', 'b', 'c', 'd', 'n'}; while(j < g) { for(i = 0; i < 80; i = i + 4)
this programm should in theory create a labyrinth but it doesnt and i really dont have the skill to pick up where i have been mistaken so gcc runs it but it crashes and it doesnt produce any remarkable results even when it runs.... for example this should you run it with these parameters .
5 5
appear something like this 10111 10101 10101 10001 11111
or like this
10111 10001 11101 10001 11111
but it only crashes....it works with recursion and it makes a array (which is Ptr) a set of 1 and 0 which 0 is the path and 1 is the walls...
Code: #include <stdio.h>#include <stdlib.h> #include <time.h> int **Ptr; int M, N, P, charge, i,c,j; void Lab_creator(int vertical, int horizontal,int direction);
For some reason the integer array, arr[100][50], declared in main is not storing the correct values when passed through the function charArrayToIntArray.
I made an output right in the function to show how the array is not keeping the proper values, although when I output the array from within the loop in the function, it shows the correct values.
For example, if one researched how to deep copy a map container and paraphrased a solution from a website, what is the proper format? Are there standards for citing works in code?
I am currently only citing the link to the source in my personal code and explaining what algorithm the source contains.
I am creating a right hand maze solution, and it actually works for the most part, but it gets stuck at the sixth spot and will not proceed any further. I cannot seem to find my error even though I know it's probably a small one in my code, here is what I have at the moment:
I have an application that uses an array of threads to call a method along with thread.join(). I was just wondering what would be the best way to handle the thread in case if one of the thread fails? Should I put a try catch block on the method that is being called or should I put the try catch block on the array of threads, or is there any other proper way to handle failed threads?
I'm trying to write a wrapper for rapidXML in order to use it in my projects however I've run into a curious bug that's preventing me from properly saving the XML documents I'm working with. The gist of it is: simply parsing a very simple xml doc and then saving the same document to the same file (without modifying it) creates a mostly correct output except for scrambling a few node closures:
As a foot note: I'm almost certain it's not an issue with the parse() function.
If I parse() the document and then call std::cout<<doc; it prints the document perfectly fine to the console, but for some reason std::ofstream<<doc; causes issues.
I'm writing a program where the user inputs a number of rows, and that many rows of @ symbols are printed, where the first row has the same number of columns as rows, and each next row decrements the number of columns by 1. It prints out a totally wrong output and whatever I try it won't print the right thing- currently when I input 4 it prints out 5 @ symbols on the first row, and then 3 on all the other rows.
Code:
#include <iostream> using namespace std; int main ( ) { int rows; cout << "How many rows? "; cin >> rows;
I would like to know how to make Lynx follow meta refresh links automatically, At the moment it just provides a "clickable" link you can accept the refresh. I would like this to be automatic.
--- Initial problem ---
We have a DB Backup script written in PHP/HTML and uses the page refresh to loop the backup (every 2 minutes). Using a full fledged browser is not really an option on our machine as the resources are very tight. So we tried Lynx and it has the perfect footprint but the only problem is it doesn't refresh the page.
I'm thinking I just need some way to force Lynx to reload the page after the time has elapsed. Maybe create a new function that starts a timer and hold the url until the timer ends then force Lynx to visit that url. Im a PHP Procedural kinda guy and I cant think how to set this timer event safely without corrupting or crashing the program or creating memory leaks.
(source code im using: [URL])
This is the function that handles meta refresh.
Code: /* * Given a refresh-URL content string, parses the delay time and the URL * string. Ignore the remainder of the content. */ void LYParseRefreshURL(char *content, char **p_seconds, char **p_address)