Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Counting vowels in string. "Comparison pointer-integer". Post 302579433 by fakuse on Monday 5th of December 2011 05:34:02 PM
Old 12-05-2011
Question Counting vowels in string. "Comparison pointer-integer".

I'm trying to write a programme which scans strings to find how many vowels they contain. I get an error saying that I'm trying to compare a pointer and an integer in
Code:
if(*v == scanme[i]){

. How can I overcome this ? Also, the programme seems to scan only the first word of a string e.g.: if I type "abc de" it will only scan "abc". (I know this because for some reason it didn't produce the pointer-integer error before).

Thank you in advance.

Code:
#include<stdio.h>
#include<string.h>

int main ()
{
        char scanme[80];
        char *v[80] = {"a", "e", "i", "o", "u"};
        int nv = 0;
        int i;
        printf ("Type a string to scan.\n");
        scanf ("%s", scanme);
        printf ("Looking for vowels in \"%s\"...\n", scanme);


        for(i = 0; i < strlen(scanme); i++){
                if(*v == scanme[i]){
                        nv++;
                }
        }
        printf ("There are %d vowels.\n", nv);

        return 0;
}

 

10 More Discussions You Might Find Interesting

1. Programming

comparison between pointer and integer

I received a warning when I tried to compile my program that said: warning: comparison between pointer and integer Could you please explain to me what this means, and in what ways I could possibly fix this? Thanks for your help! (2 Replies)
Discussion started by: sjung10
2 Replies

2. Shell Programming and Scripting

input string="3MMTQSZ348GGMZRQWMJM4SD6M";output string="3MMTQ-SZ348-GGMZR-QWMJM-4SD6

input string="3MMTQSZ348GGMZRQWMJM4SD6M" output string="3MMTQ-SZ348-GGMZR-QWMJM-4SD6M" using linux shell script (4 Replies)
Discussion started by: pankajd
4 Replies

3. Shell Programming and Scripting

cshell integer expression from "0000" to "1999"

I have 2000 files named like "file-fr0000.log", "file-fr1999.log"... I wanna generate the file names automatically in the following c shell script: set fr = 0 while ($fr <= 1999) grep "ENERGY" file-fr$fr.log > data.dat @ fr = ( $fr + 1 ) end The above will generate file names... (3 Replies)
Discussion started by: rockytodd
3 Replies

4. Programming

php stop "internal row pointer" when fetch from mysql

Hi gurus, I need to call php function for fetching data from mysql but I dont want to move internal row pointer (IRP) forward. Or even get the actual IRP position then fetch data and move IRP back to remembered position. Function mysql_data_seek() is not suitable for my example because I am trying... (1 Reply)
Discussion started by: wakatana
1 Replies

5. Programming

warning: comparison between pointer and integer

Hi guys :D I am still playing with my C handbook and yes, as you can see I have small problem as always :cool: I wrote a C code #include <stdio.h> #define MESSAGE 100 int main(void) { char input_mes - Pastebin.com And when I try to compile it I get following errors from gcc ... (1 Reply)
Discussion started by: solaris_user
1 Replies

6. Shell Programming and Scripting

Using sed to find text between a "string " and character ","

Hello everyone Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) "string " and before a ",". I have tried sed -n 's/.*string \(*\),.*/\1/p' filewith some, but limited success. This gives out all... (10 Replies)
Discussion started by: haggismn
10 Replies

7. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

8. Shell Programming and Scripting

tcsh - understanding difference between "echo string" and "echo string > /dev/stdout"

I came across and unexpected behavior with redirections in tcsh. I know, csh is not best for redirections, but I'd like to understand what is happening here. I have following script (called out_to_streams.csh): #!/bin/tcsh -f echo Redirected to STDOUT > /dev/stdout echo Redirected to... (2 Replies)
Discussion started by: marcink
2 Replies

9. Shell Programming and Scripting

grep with "[" and "]" and "dot" within the search string

Hello. Following recommendations for one of my threads, this is working perfectly : #!/bin/bash CNT=$( grep -c -e "some text 1" -e "some text 2" -e "some text 3" "/tmp/log_file.txt" ) Now I need a grep success for some thing like : #!/bin/bash CNT=$( grep -c -e "some text_1... (4 Replies)
Discussion started by: jcdole
4 Replies

10. Shell Programming and Scripting

Delete all log files older than 10 day and whose first string of the first line is "MSH" or "<?xml"

Dear Ladies & Gents, I have a requirement to delete all the log files in /var/log/test directory that are older than 10 days and their first line begin with "MSH" or "<?xml" or "FHS". I've put together the following BASH script, but it's erroring out: for filename in $(find /var/log/test... (2 Replies)
Discussion started by: Hiroshi
2 Replies
thai/wtt.h(3)							      libthai							     thai/wtt.h(3)

NAME
thai/wtt.h - WTT I/O implementation. SYNOPSIS
Enumerations enum WTTClass { CTRL = 0, NON = 1, CONS = 2, LV = 3, FV1 = 4, FV2 = 5, FV3 = 6, BV1 = 7, BV2 = 8, BD = 9, TONE = 10, AD1 = 11, AD2 = 12, AD3 = 13, AV1 = 14, AV2 = 15, AV3 = 16 } Classification of characters in TIS620 according to WTT. enum WTTOp { CP = 1, XC = 2, AC = 3, RJ = 4, SR = 5 } Composibility checking tables. Functions WTTClass TACchtype (thchar_t c) WTT character class. WTTOp TACio_op (thchar_t c1, thchar_t c2) WTT I/O operation. Detailed Description WTT I/O implementation. WTT stands for Wing Tuk Tee (in Thai, Runs everywhere). It was defined by TACTIS (Thai API Consortium/Thai Industrial Standard) in the NECTEC Thai Software Standard Project (1989-1991), and later endorsed by Thai Industrial Standard Institute (TISI) as TIS 1566-2541 in 1998. WTT classifies Thai chracter(TIS-620) into 17 types below. ITYPE VALUE SHORT_DESCRIPTION CTRL 0 control characters NON 1 non composible characters CONS 2 consonants LV 3 leading vowels FV1 4 following vowels 1 FV2 5 following vowels 2 FV3 6 following vowels 3 BV1 7 below vowels 1 BV2 8 below vowels 2 BD 9 below diacritics TONE 10 tonemarks AD1 11 above diacritics 1 AD2 12 above diacritics 2 AD3 13 above diacritics 3 AV1 14 above vowels 1 AV2 15 above vowels 2 AV3 16 above vowels 3 Functions in thctype.h do basic character classifications while wtt.h classifies a chracter in detail. Please refer to the reference. TACio_op() checks how to compose two given chracters. The possiblities are Composible (CP), Non-display (XC), Accept (AC), Reject (RJ) and Strict Reject (SR). The values of CP, XC, AC, RJ and SR are difined in wtt.h. And their meanings are: o CP : second character is displayed in the same cell as the first, also implies an acceptance. o XC : Do nothing. o AC : Display second character in the next cell. o RJ : Discard second character. o SR : Reject second character only in strict mode. Enumeration Type Documentation enum WTTClass Classification of characters in TIS620 according to WTT. Enumerator CTRL control chars NON non composibles CONS consonants LV leading vowels FV1 following vowels 1 FV2 following vowels 2 FV3 following vowels 3 BV1 below vowels 1 BV2 below vowels 2 BD below diacritics TONE tonemarks AD1 above diacritics 1 AD2 above diacritics 2 AD3 above diacritics 3 AV1 above vowels 1 AV2 above vowels 2 AV3 above vowels 3 enum WTTOp Composibility checking tables. Enumerator CP COMPOSIBLE - following char is displayed in the same cell as leading char, also implies ACCEPT XC Non-display AC ACCEPT - display the following char in the next cell RJ REJECT - discard that following char, ignore it SR STRICT REJECT - REJECT only if in strict mode Function Documentation WTTClass TACchtype (thchar_tc) WTT character class. Parameters: c : the character Returns: WTT character class { CTRL, ..., AV3 } WTTOp TACio_op (thchar_tc1, thchar_tc2) WTT I/O operation. Parameters: c1 : previous character c2 : next character Returns: WTT I/O operation { CP, XC, AC, RJ, SR } Author Generated automatically by Doxygen for libthai from the source code. Version 0.1.14 Tue Jun 17 2014 thai/wtt.h(3)
All times are GMT -4. The time now is 04:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy