Sponsored Content
Homework and Emergencies Homework & Coursework Questions Function to Check if string input from user is alphabetic only Post 302770944 by eracav on Tuesday 19th of February 2013 06:22:28 AM
Old 02-19-2013
Function to Check if string input from user is alphabetic only

Good Evening. I'm new to C. Can you please help me.
I'm creating an error checking function, user will input a string, this will check if the input is all alphabet or all letters only. If there is a digit or other special char, it will print Error then ask input from user again.


Here's my code. I don't know what's wrong

int isValid (const char str[], const int max) {
int i;
for (i=0; i<= max; i++) {
if (isdigit(str[i])) {
printf("Letters and spaces are only allowed\n");
return 1;

}

else {

return 0;

}
}
}





I'm from the Philippines. Thank you very much.

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash : how do i check the user input and make sure is only chracter or only number ?

Bash : how do i check the user input and make sure is only character or only number ? (7 Replies)
Discussion started by: CheeSen
7 Replies

2. Shell Programming and Scripting

Quick regex question about alphabetic string

Hi guys, Pretty new to regex, and i know im doing something wrong here. I'm trying to get a regex command that restricts a string to be 8 characters long, and the first character cannot be 0. Here's what i have so far... echo "01234" | grep "^{8}*$" Thanks very much! -Crawf ... (7 Replies)
Discussion started by: crawf
7 Replies

3. UNIX for Dummies Questions & Answers

how to check the user input from terminal

Hello everybody!!! I am writing my own rm command in unix. I prompt the user to type if he wants to delete a file and then read what he typed. But how do i check what he typed? This is my program so far: echo 'Delete prog1.c (y/n)?' read yesOrNo if yesOrNo == 'y' then rm prog1.c... (6 Replies)
Discussion started by: mskart
6 Replies

4. Shell Programming and Scripting

String generation from user input

Hi I have one thing I need advice on, and I don't know where to start so I have no sample code. I want the user to provide input like: 1-3,6,7,9-11 When the input is like this, I want a string to be generated including all the numbers. In the example above, the string would look like: 1... (13 Replies)
Discussion started by: Tobbev
13 Replies

5. Shell Programming and Scripting

Check user input

Hi, I need my script to check if the user enters 3 values if not 5 values to my script and alert if the input has any other number of values. for example: ./myscript.sh 22 56 3221 - > correct ./myscript.sh 22 56 3221 45 777 -> correct ./myscript.sh 22 56 3221 45 -> incorrect Please... (6 Replies)
Discussion started by: mohtashims
6 Replies

6. Shell Programming and Scripting

How-To Check & Filter user input

Hi, On my Java webpage which invokes the shell script has two checkboxes viz ... apache and weblogic apache require one parameter i.e apache home from the user while Weblogic requires three or five params from the user vi.z weblogic_home or <jdk_home, config_home & pid>, username and... (4 Replies)
Discussion started by: mohtashims
4 Replies

7. Shell Programming and Scripting

How to check the user input to be valid using shell script?

How to check the user input to be valid using shell script? The valid input is in the format like as follows. 1. It can only have r,w,x or a hyphen and nothing else. 2. ensure the r, w, x are in the correct order. for example: rwxr-xr-x is a valid format. Thanks (5 Replies)
Discussion started by: hyeewang
5 Replies

8. Shell Programming and Scripting

Automaticaly create function based off user input

I am trying to create a bash script that will create new function by using the user input. The below will create the necessary files in the correct format, however when it comes to the # create function I am at a loss. If the name entered was NEWNAME and the genes were GENE1,GENE2 then two files... (0 Replies)
Discussion started by: cmccabe
0 Replies

9. Shell Programming and Scripting

Insert a user input string after matched string in file

i am having file like this #!/bin/bash read -p 'Username: ' uservar match='<color="red" />' text='this is only a test so please be patient <color="red" />' echo "$text" | sed "s/$match/&$uservar\g" so desireble output what i want is if user type MARIA this is only a test so please... (13 Replies)
Discussion started by: tomislav91
13 Replies

10. Shell Programming and Scripting

Would like to check user input for letters within a loop

Hi All, #!/bin/bash #Just trying to check if letters are in the user input. Any tips? # I have tried regexp and using 0-9 etc, i cannot get this to work either in just an if statement or while in a loop. echo "Please pick a number" read num if ; then echo "Please enter a number"... (7 Replies)
Discussion started by: jvezinat
7 Replies
PLSTRING3(3plplot)						    PLplot API							PLSTRING3(3plplot)

NAME
plstring3 - Plot a glyph at the specified 3D points SYNOPSIS
plstring3(n, x, y, z, string) DESCRIPTION
Plot a glyph at the specified 3D points. (Supersedes plpoin3(3plplot) because many[!] more glyphs are accessible with plstring3(3plplot).) Set up the call to this function similar to what is done for plline3(3plplot). The glyph is specified with a PLplot user string. Note that the user string is not actually limited to one glyph so it is possible (but not normally useful) to plot more than one glyph at the speci- fied points with this function. As with plmtex(3plplot) and plptex(3plplot), the user string can contain FCI escapes to determine the font, UTF-8 code to determine the glyph or else PLplot escapes for Hershey or unicode text to determine the glyph. Redacted form: plstring3(x, y, z, string) This function is used in example 18. ARGUMENTS
n (PLINT, input) Number of points in the x, y, and z arrays. x (PLFLT *, input) Pointer to an array with X coordinates of points. y (PLFLT *, input) Pointer to an array with Y coordinates of points. z (PLFLT *, input) Pointer to an array with Z coordinates of points. string (const char *, input) PLplot user string corresponding to the glyph to be plotted at each of the n points. AUTHORS
Geoffrey Furnish and Maurice LeBrun wrote and maintain PLplot. This man page was automatically generated from the DocBook source of the PLplot documentation, maintained by Alan W. Irwin and Rafael Laboissiere. SEE ALSO
PLplot documentation at http://plplot.sourceforge.net/resources. August, 2012 PLSTRING3(3plplot)
All times are GMT -4. The time now is 05:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy