Programming :: Data Validation - Input Contains Digits And Certain Alphabets

Apr 8, 2010

I am having a huge problem checking the data I input to make sure it is correct. What I am trying to achieve is when I input a value, it will check if the input is all digits and if it is not, check to see if it contains certain alphabets. Thus for example, if I were to input in data such as "11A" , the program will then inform me "There is an important alphabet in the program." This would be my expected output. Here is the program I have wrote...

Code:
int test(string r ){ const int arraySize = 10;
char array2[arraySize2] ={'A','B','E','F','G','H','J','K','N','O','P','Q','R','S','T','U','W','Y','Z'};
for(int cntr = 0; cntr <r.length(); cntr++)
if(!isdigit(r[cntr])){ for(int new1 =0; new1<arraySize2;new1++)
for(int cntr1 = 0; cntr1 <r.length(); cntr1++)
if(array2[new1] == r[cntr1]){ return 2; //will return2 when it finds the same
// char in the array and the string r. } else{ return 3;
//will return 3 when there is a char
//in the string which isnt in the array
} } else { return 1; // will return 1 when string is all digit.
} int main() { string r = "11D"; test(r);
if(test(r) == 1) { cout << "ALL ARE DIGITS" << endl;
} if (test(r)== 2) {
cout << "There is an important alphabet in the program." << endl;
} if (test(r)== 3) { // testRoman(r);
cout << "There is an Alphabet in the String which is not in the Array" << endl;
} }

So, the problem I am facing is when I input in data such as 11 or A , the prog will come out the right input. But if I were to put in data such as "11A" , the output coming out will be "ALL ARE DIGITS". The problem which causes this seems to be in the return statement , as once as it finds the first char which is a digit, it will then return 1 and not continue checking the rest of the string. Is there a way I can stop or continue a loop if it has met the condition I stated? What I can do or any other way available for me to check my input?

View 4 Replies


ADVERTISEMENT

Programming :: Checking For Alphabets ?

Jan 25, 2010

Code:

I am trying to do a search to check if the input is using alphabets and nothing else.

I tried using [[:digit:]] and [[:alpha:]] but none seems to work

When i use digit, it read 22.k as alphabet and not as a wrong syntax.

For alpha , it does not allow me to input data which has spaces such as " hello world".

View 1 Replies View Related

Programming :: Perl: Compare CGI Input With Data From A MySQL Table?

Nov 19, 2008

I have this program:

#! /usr/bin/perl
use DBI ;
use strict ;

[code]....

and I get this error simply running the program from the command line: DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 at ./submit.cgi line 24.

is this the right syntax to use, both, for this line:

my (@param) = $cgi->param("firstname","lastname","type") ;

as well as this one:

$sth=$dbh->prepare ("SELECT firstname,lastname,type FROM dts WHERE firstname LIKE $param[0] AND lastname LIKE $param[1] and type LIKE $param[2]" );

or should there be quotes around the $param[0] or something? (also is it $param[0] or $param(0)?)

View 1 Replies View Related

Programming :: Using Piped Data As Input - Cannot Stat '-': No Such File Or Directory

Nov 6, 2010

Code: stuart@stuart:~/$cat showthread.php.html | grep -o [URL][^"< ]*" | uniq | head -n3 | plowdown - cannot stat '-': No such file or directory Code: stuart@stuart:~/$ awk NR==$x Musiclist.txt | cut -d/ -f6 | basename $1 .mp3 .mp3 Here's some system info on the bash i'm using:

[Code]...

View 13 Replies View Related

Programming :: Handle Non Argument Error While Adding Two Alphabets Using 'expr'

Feb 19, 2011

how to handle non argument error while adding two alphabets using 'expr' (not bc).

View 1 Replies View Related

Programming :: Maximum Digits In The GMP?

Mar 27, 2011

how much big number can be managed by gmp library under plain GCC environment? (does GMP cover infinite length of integer?)

View 1 Replies View Related

Programming :: Getting Number Of Digits In Uint64_t?

Jul 7, 2011

I'm having a hard time trying to get the number of digits in a uint64_t variable. The reason I'm using this is I want to make sure I get x amount of digits inside of a variable before I use it, but since the higher the digits, the better the program is.I currently use the following code, and it works, but my loop will never exit because the length is always 0:

Code:

/**
* numbdigits()
* number: The number to evaluate [in]
*
* Returns the number of digits found in a number.

[code]....

getrand() returns a uint64_t as well (and works). The only way the while() loop ends without my intervention is if I do curd += numdigits(val) instead...but, that gives a false value as well.

View 7 Replies View Related

Programming :: Replace All Digits With Symbol In String?

Aug 29, 2010

I am trying to replacee all digits with a symbol (say, big U here) in a string by

[code]...

The result become 'UsUoUmUeUtUhUiUnUgU' instead of 'somethingUUU' as expected. Looks like my string contains some 'hidden digits' in between the letters. Does anyone have an idea about that?

View 2 Replies View Related

Programming :: Form Field Validation Using PHP

Sep 10, 2009

I want to validate a web form using PHP. I spent ages confusing myself with client side scripting and realised until I worked out it is not what I want. My problem is that now I am looking at PHP and everything is mixed up in my brain. I need to point out that PHP is very new to me! This is what I already have:
1 An html page with my form on it.
2 PHP page which emails the contents of the form to me.

The above works well. For the sake of clarity, here are my pages (cut down to the essentials where appropriate): My html form:
first name surname
Email  
Home phone
Mobile
Work phone

I have read and understood your terms and conditions. My php script (regform.php)
$receiver = 'me@email'; $subject = 'New registration'; #$message = 'This is a new registration.'; $surname = $_POST['surname']; $firstname = $_POST['firstname']; $address = $_POST['address']; $email = $_POST['email']; $homeph = $_POST['homeph']; $mobileph = $_POST['mobileph']; $workph = $_POST['workph']; $time = $_POST['time']; #from here $oldaddress = $_POST['oldaddress']; $DOB = $_POST['DOB']; $elect = $_POST['elect']; $job = $_POST['job']; $salary = $_POST['salary']; $employer = $_POST['employer']; $benefit = $_POST['benefit']; $smoke = $_POST['smoke']; $claim = $_POST['claim']; $children = $_POST['children']; $children2 = $_POST['children2']; $pets = $_POST['pets']; $pets2 = $_POST['pets2']; $require = $_POST['require']; $terms = $_POST['terms']; $rooms = $_POST['rooms']; $body = "first name:$firstname
surname:$surname
DOB:$DOB
email:$email
home phone:$homeph
mobile phone:$mobileph
work phone:$workph
address:
$address
time at this address:$time
previous address:$oldaddress
electoral register:$elect
employment:$job
employer:$employer
salary:$salary
benefit claim:$benefit
future benefit:$claim
children:$children
ages:$children2
pets:$pet
pet type:$pets2
other requirements:$require
terms:$terms"; $headers = 'From: email' . "
" . 'Reply-To: email "
" . 'X-Mailer: PHP/' . phpversion(); mail($receiver, $subject, $body, $headers, "From: $firstname $surname
" . "Reply-To: $firstname $surname class="inlineimg" />;

You can see there are many more form fields than I have shown in my example html form above. What I want is that the following fields have to be filled:
1 mobileph
2 email
3 terms (checkbox)
I would like the user to be asked to fill the form in properly if any/all of the 3 fields have not been filled in. I imagine I need some php in the html page and some more in the php page. I am certainly not asking any one to do this for me but I am really confused. I have googled and copied and pasted and edited for 6 hours and I am lost. What I want is a very simple and clear example of the code needed. Sorry if I sound as if I can't search properly on Google: in this case I clearly can't!

View 2 Replies View Related

Programming :: Rename Files Recursively, Only Keeping Last X Digits Plus Extension?

Nov 29, 2009

My problem is this:I have a number of directories, all containing files of different name lenghts, including letters, numbers and possibly spaces. I want to recursively rename all of these files, so that only the _last_ 5 digits (not counting the extension) remain. In other words: I want to cut off all but the last 5 digits and not touch the extension.

I've tried to read up on tr, rename (perl version), sed, cut etc. and browsed through some threads here, but so far couldn't quite figure out how to do it.

If someone could point me to the right (standard) CLI tools and syntax.

View 2 Replies View Related

Programming :: If Test Validation - Using Char Arrays

Jun 9, 2010

I'm writing a code to get the index of the last occurrence of a given substring in a string.

Code:
int StringHandler::lastIndexOf(string src, const string s) {
unsigned int lastIndex = string::npos;
if (src.find(s, 0) == string::npos) {
return -1; } else {
bool isLast = false; unsigned int i = 0; do {
lastIndex = src.find(s, i);
if (lastIndex != string::npos) { i = lastIndex + 1;
if (i == src.size()) { isLast = true;
} } else { isLast = true;
} } while (!isLast);
} return lastIndex;
}

My problem is: execution steps into an if with a false condition! Check the values of i and src.size() at the right panel. How could be possible for the program to run the highlighted statement? The if condition above is false! [URL]. I could use char arrays, for example, but this kind of false validation has happened to me more than once, I'm using G++ 4.5 with these flags: -O0 -g -Wall -c

View 3 Replies View Related

Programming :: Perl Script - Phone Number Validation

Apr 1, 2010

I am doing a perl script validation for Phone numbers. The normal phone number format is 01-32145. I need to do two validations for the phone number

1) A valid phone number can have at least two digits as prefix and at least five digits as postfix. e.g. 01-01011
2) A valid phnoe number can't contain only the digit "0" in either area code or phone number e.g. 00-11111 or 01-00000 is not allowed.

I am able to do the first validation, but not the second. I am pasting my code part here. How to add the second validation inside my current code.

open(TMPOUTPUT, "<$tmp_output_file") or die "Can't open output";
open(OUTPUT, ">$output_file") or die "Can't open output";
while ($line = <TMPOUTPUT>) { $line =~ s/ +
//; ($cur_phone, $xxxxxx, $xxxxxx) = split(";", $line);
($cur_phone_prefix, $cur_phone_postfix) = split("-", $cur_phone);
$length_prefix = length ($cur_phone_prefix);
$length_postfix = length ($cur_phone_postfix);
if ($length_prefix < 2 || $length_postfix < 5 ) {
print "Invalid phone number: $cur_phone ";
} else { print "Valid phone number: $cur_phone ";
} } close TMPOUTPUT; close OUTPUT;

View 9 Replies View Related

Ubuntu :: Data Could Not Be Written (Input/output Error)

Oct 18, 2010

i tried to rip a dvd last night and it got 98% done then said "Data could not be written (Input/output error)"here is the error log from brasero

Checking session consistency (brasero_burn_check_session_consistency brasero-burn.c:1744)
BraseroDvdcss called brasero_job_get_action
BraseroDvdcss called brasero_job_get_action

[code]....

View 2 Replies View Related

General :: Festival C++ API And Pthread() - Takes Raw Data From Sensors On The Input

Oct 21, 2010

I am attempting to write a program using Festival as the TTS output. It is a weather system, so

1) takes raw data from sensors on the input.
2) converts it into a text message
3) let festival take the message and turn it into audio that I can then route out to the telephone system.

Here is my main block of code using festival:

[Code]...

I imagine some of my problem is being a C/C++ newbie, but is there anybody out there able to give me some hints? Maybe there is a different or better way to fork that process. My plan is to keep updating the buffer whose pointer is passed to the function process() with my serial port processing program in the main loop. I can protect it with a mutex during the festival_say_text() function, but otherwise it will be accessible.

View 1 Replies View Related

Programming :: Get Data From Serial Port Function Read() Blocks When Data Not Available?

Jun 11, 2009

I am using read() in c++ to get data from a serial port. However, if no data is available on the serial port the function blocks until dta arrives.Example code:

//------------------------------------------------------------
char m_readBuffer[255] = {0};
char* p_curChar = m_readBuffer;

[code]...

View 1 Replies View Related

OpenSUSE :: Firefox Font - Gaps In Alphabets Are Making Them Difficult To Read

Jul 9, 2010

I am facing some problems in font rendering issue for Urdu (South Asian language). Actually the alphabets are being displayed as, for example, "a p p l e" instead of "apple" - if you see this website, probably you will see the gaps in alphabets are making them difficult to read.

I have installed at least 10 different Urdu fonts but still no help, then I tried adding:

MOZ_DISABLE_PANGO="0" to /etc/environment but it also did not helped.

I am using OpenSuse 11.2, Firefox 3.5.10

View 7 Replies View Related

Ubuntu Installation :: Copying Data Setup Tells About An Input/Output Error?

Dec 20, 2010

I want to install Xubuntu 10.10 x64, but it does not work. While copying data the setup tells me about an Input/Output error, but i don't think there are hardware errors.

The environment:

AMD Phenom II 1055t 6x2,8 Ghz
2x 2gb ram
Hitachi 1TB hard drive
Two partitions: 1st for Windows 7 Ultimate (NTFS), 2nd for my Data (NTFS)

So I decreased the size of the data partition and created two new partitions beside the Win7 partition and the data partition. The first is ext4-journal (20gb) the second is Swap (4gb). I've done that all by the Xubuntu setup.

I've downloaded the image from the german mirror (TU Chemniz) and checked the integrety via SHA1. Checksum was correct. I also checked the data after burning.

View 4 Replies View Related

Programming :: Data Directory In Automake - Data Is Always Read-only ?

May 9, 2010

I have some data files that should be distributed with my program. Using dist_pkgdata_DATA in Makefile.am, I get these files installed to /usr/local/data/share/package-name. The problem is that data is read-only, and my program needs to modify it. Playing with dist_sharedstate_DATA, dist_localstate_DATA, dist-data_DATA varibles, I got different installation directories, like /usr/local/com, usr/local/var, but data is always read-only.

How can I distribute modifiable data files with my package? I need some common directory for all users, or maybe local data in a user directory.

View 1 Replies View Related

Programming :: Shell Programming - Delete User Input

Jan 21, 2011

I recently started shell programming and my task now is to do a menu display.Currently i am stuck whereby user will input both title and author and it will delete it.

Do i have to use sed command?

View 4 Replies View Related

Software :: How To Get File Permission As Digits

Jun 28, 2010

I am trying to write a program that gets file permission. I understand linux has ls -l can view file permission, but it has too many information that I have to process those strings in my program. Is there an easier command just return me the permission digits like:
$ getperm /home/file
0440
$

View 1 Replies View Related

General :: Bash Script - Read File Name With Two Digits?

Jun 20, 2011

I have many files with name in order of number. e.g)

u0101.asc
u0102.asc
u0103.asc

[code]...

I am trying to read file using for loop.

for ((date=01; date<=31; date++))
do
echo ${date}
done

but '01' is read(print) as '1' How can I make it read from '1' to '01'?

View 6 Replies View Related

General :: Count The Numerical Digits In Between The Text Using A Command Or A Script?

Jan 1, 2010

I want to count the digits in between the text in a file.

e.g.

write down the form

2.3 3.3 3.0 505.0 0.777E-07

22.3 3.3 5.0 503.0 1.777E-04

Then read this.

How can i do the counting of these digits present in between a text in a file?

View 9 Replies View Related

Ubuntu :: Get Offline Web Validation Apps?

Apr 22, 2010

I've just finished my 100% total move from Windows after 2 years of developing on two different systems, one Slackware and one XP. I have come away from Slack because it was just taking too long to maintain the rapid advances in development tools and have now moved onto Ubuntu full time.

The last tool I was using on Windows was Dreamweaver, and not for editing (I had Bluefish for that) but for the HTML validation that worked offline. Thing is, I now can't find anything similar on Ubuntu. I've no idea how to get the W3C Validators working offline and the last two add-ons I tried with Firefox didn't work. Anybody know of any packages with reliable HTML and CSS validation that works offline? An offline link checker would also be useful.

View 1 Replies View Related

General :: NS2 - Some Validation Tests Failed

Jun 11, 2009

After many modifications, I managed to install ns2.28 , but some validation tests failed. I got the following message at the end of validation test:

validate overall report: some tests failed:
./test-all-simple ./test-all-tcp ./test-all-testReno ./test-all-newreno ./test-all-sack ./test-all-tcpOptions ./test-all-sack-full ./test-all-tcpVariants ./test-all-LimTransmit ./test-all-aimd ./test-all-greis ./test-all-rfc2581 ./test-all-sctp ./test-all-tcpHighspeed ./test-all-frto ./test-all-friendly ./test-all-srm ./test-all-realaudio ./test-all-ecn ./test-all-ecn-full ./test-all-quickstart ./test-all-hier-routing ./test-all-lan ./test-all-mcast ./test-all-vc ./test-all-mixmode ./test-all-red ./test-all-adaptive-red ./test-all-red-pd ./test-all-rio ./test-all-vq ./test-all-rem ./test-all-gk ./test-all-pi ./test-all-cbq ./test-all-schedule ./test-all-jobs ./test-all-intserv
to re-run a specific test, cd tcl/test; ./test-all-TEST-NAME

Notice that some tests in webcache will fail on freebsd when -O is turned on. This is due to some event reordering, which will disappear when -g is turned on. I tried to run the test individually one after another, but that is too time consuming, it prompts for permission after every test and thus runs many test & opens a lot of xgraph window. The tests I run so far individually, agreed with the reference output. Now I am wondering, should I report a bug about it, or should I hire a kid to run those failed 40 tests( which require hitting the ENTER key 1200 times,maybe ), or what else should I do.

View 14 Replies View Related

Security :: End User Validation Using Squid

May 24, 2009

This question is regarding squid based security. We would like to enforce browser security onto our users and would like to know if anyone has performed this. Our goal is to check a users browser version/plugin level before allowing them to access the internet in our organization. If their browser does not meet a standard compliance level such as patches or if they are using i.e. 5.0 we would redirect them to a page telling them that they need to update their browser before access will be permitted. Has anyone performed any types of checks like these?

View 4 Replies View Related

Fedora :: Regular Expressions And E-mail Validation?

Jan 12, 2010

The * would not have to be because it means everything [az] [0-9 ][$%&!"/()=?'=) but not how to solve[URL]..

ls [0-9a-zA-Z]*[@]*[gmail | yahoo | hotmail]*[.]*[com]
ls [0-9a-zA-Z][.-_][0-9a-zA-Z]*[@]*[gmail | yahoo | hotmail]*[.]*[com]

View 2 Replies View Related

Ubuntu :: Quick Command Line Validation?

Dec 17, 2010

sudo mkdir /etc/adobe=(created a directory in /etc named Adobe)correct?echo "OverrideGPUValidation=true" >~/mms.cfg=(created a text file in my Home directory named mms.cfg which contained the text...OverrideGPUValidation=true...correct?sudo mv ~/mms.cfg /etc/adobe/=(moved from my Home directory to /etc/adobe mms.cfg) correct?These commands were part of a flash tutorial but they did not work.So I cd'd into etc and using sudo tried rm -r /adobe. Basically Iwant to undo what those 3 commands did.Link to tutorial=(Flash in fullscreen is choppy, completely white or crashes)[URL]

View 4 Replies View Related

General :: Validation Failed In NS2.34 In Ubuntu 10.04 64bit

May 11, 2011

I have just installed NS2.34 in my Ubutun 10.04. I have installed it successfully, but I got some failures in validation.

Validate overall report: all portable tests passed but some non-portable tests failed:
./test-all-srm ./test-all-smac-multihop ./test-all-hier-routing ./test-all-algo-routing ./test-all-mcast ./test-all-vc ./test-all-session ./test-all-mixmode ./test-all-webcache ./test-all-mcache ./test-all-plm ./test-all-wireless-tdma

I read the post of [SOLVED] Validation failed in NS2.34 in ubuntu 10.04 remix and followed the steps there. But, the same problem remains. I think the problem may be due to my 64-bit operating system.

View 2 Replies View Related

General :: Validation Failed In NS2.34 In Ubuntu 10.04 Remix

Aug 28, 2010

I have installed Ubuntu 10.04 remix in my new hp mini 110 netbook and I have succeeded in installing NS2.34 after a so many trials but now after running ./validate some of the tests have failed. Is my ns2 installation not successful?

Some non-portable tests also failed:
./test-all-srm ./test-all-smac-multihop ./test-all-hier-routing ./test-all-algo-routing ./test-all-mcast ./test-all-vc ./test-all-session ./test-all-mixmode ./test-all-simultaneous ./test-all-webcache ./test-all-mcache ./test-all-plm ./test-all-wireless-tdma ./test-all-satellite to re-run a specific test, cd tcl/test; ./test-all-TEST-NAME

View 6 Replies View Related

Programming :: Input And Output On C++ Programming ?

Jan 28, 2010

As i am new to C++ i couldn't figure out how to input a file and make some change on the file and produce a output file. like this problem i have is.

"Program that processes an input file and produces an output file. The input file will contain lines of data, each containing two floating point numbers. The lines of the output file should contain the two numbers read and their average (with a '$' sign and 2 places after the decimal point)."

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved