logo
down
shadow

Comparing ASCII value of input (C Program)


Comparing ASCII value of input (C Program)

By : Dwasati Zhyan
Date : November 16 2020, 06:23 AM
seems to work fine For practice I am trying to create a program that counts the number of each digit, alphabetic character, and "whitespace" character in a line. , You need to fix the digits counter:
code :
if (c >= '0' && c <= '9') {
  ++CountDigits[c];
}
if (c >= '0' && c <= '9') {
  ++CountDigits[c - '0'];
}


Share : facebook icon twitter icon
Reading, Comparing and taking input non ASCII charachter(i.e Bangla and other indic script) array in C

Reading, Comparing and taking input non ASCII charachter(i.e Bangla and other indic script) array in C


By : Shayan Zahrai
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Can I work with Begali charachters(non ASCII) in C? , Absolutely. Look into libiconv or ICU.
Java Eclipse console terminates program before comparing values of user input and string value

Java Eclipse console terminates program before comparing values of user input and string value


By : user3037861
Date : March 29 2020, 07:55 AM
hop of those help? The problem is how you're comparing the strings. Change b == "okay" to b.equals("okay") Change all the == comparisons to .equals() or .equalsIgnoreCase(). For negations, use (!(c.equals("okay"))
In Java, == will compare primitive types by value but will compare objects by memory address. In other words, when you say b == "okay" its not doing a value comparison, its checking to see whether or not those two objects point to the same memory address, which of course is false.
code :
String [] instr = {"Add 2", "Add 11", "Subtract Original"};//array of directions
String [] invalidResp = {"Wrong", "You can't spell", "Try Again", "No"};//array of responses to print if user doesnt type 'okay' properly
int instrCounter = 0;//you don't really need this but it helps with readability
String userInput = "";//only string object you'll need =)

while (instrCounter < instr.length){//I couldve just as easily used a for loop instead.
   userInput = scan.nextLine();
   while (!userInput.equals("okay")){
      userInput = scan.nextLine();
      System.out.println(invalidResp[(int)   (Math.random()*invalidResp.length)]);
   //will print a random invalid response from the invalidResp array
      System.out.println(userInput + " is not how you spell okay");
   }//end while
   System.out.println("Great, now, " + instr[instrCounter]);
   instrCounter++;
}//end outer while
How to pass HEX character with no corresponding ASCII to a C program as input

How to pass HEX character with no corresponding ASCII to a C program as input


By : DougM
Date : March 29 2020, 07:55 AM
this will help I was able to resolve this issue by escaping the null character with Ctrl+ @
perl program to validate user input by comparing existing array

perl program to validate user input by comparing existing array


By : Andrea Cassani
Date : March 29 2020, 07:55 AM
This might help you Well, a short search of this site would lead me to believe you are over-complicating things:
code :
#!/usr/bin/env perl

use strict;
use warnings;

my (@not,@arr);
@arr=qw/cat rat mat sat/;

foreach (@ARGV)
{

        push(@not,"$_") unless ( "$_" ~~ @arr );
}
print "@not\n";
Getting error in an array comparing program in a specific input

Getting error in an array comparing program in a specific input


By : user2649742
Date : March 29 2020, 07:55 AM
I wish this help you You have an out of bound access, which yields undefined behavior. Recall that indices into raw arrays start with zero, not with one. Hence,
code :
int i = 0;
while (i < x) { /* ... */ }
i = 0;
while (i < x) { /* ... */ }

for (int a = 0; a < x; a++) { /* ... */ }
Related Posts Related Posts :
  • C - Get pointer adress to string
  • how to start a function using a Struct?
  • Trying to tweak sscanf() to ignore \n and \t
  • How to find the inverse of a Rectangular Matrix in C using GSL
  • sizeof() showing different output
  • How to select/read/copy values after specific character in a string
  • Jump from bootloader generates exception
  • Array dropping values, picks up garbage
  • Swig: Syntax error in input(3)
  • multiple definition and making sure function is correctly written
  • MD4 openssl core dumped
  • Undefined-Behavior at its best, is it -boundary break? -bad pointer arithmetic? Or just -ignore of aliasing?
  • Why am i getting problem3.c:20:23: error: expected expression before ‘int’?
  • Right Justified Zero filled String in C
  • C Function with parameter without type indicator still works?
  • How to transmit data from an interrupt handler to an user application?
  • Why do I get the error "bash: ./a.out: Permission denied" when I execute a C program in Linux mint 15
  • syntax of sigchld and its declaration
  • error using g_idle_add() in C++, same thing works in C
  • why if else or nested if else are called single statement in C
  • How do I interpret this printf in C
  • load the functions of a shell script without executing it
  • Is FilterSendNetBufferLists handler a must for an NDIS filter to use NdisFSendNetBufferLists?
  • How to write to flash memory using inline assembly?
  • More Return Statements vs. More Indentation
  • How to show an image on a PictureBox from resource?
  • Having malloced some memory,I could't calculator the proper size of the memories I malloced.I don't know why
  • What is the main difference between integer pointer and character pointer?
  • Why are some functions declared extern and header file not included in source in Git source code?
  • what is the use of fflush(stdin) in c programming
  • Is it safe to return file File descriptor locally allocated from another function In C
  • Changing undefined values of an array
  • What does an empty parameter list mean?
  • using strtol on a string literal causing segmentation fault
  • Same structure objects memory overlap?
  • C-Linux-Any way to pass command "history" to Linux shell?
  • Using #define in defining string size C
  • How to use thread pool and message queues in Multithreaded Matrix Multiplication?
  • Can't find how to select path to run a C program
  • Automatic variable in C not initialized but given fixed value within loop
  • main() function defined without return type gives warning
  • Output of following code with integer, float, char variable
  • why buffer memory allocation error in opencl
  • Why am I getting this error during run-time?
  • Strange behaviour of the pow function
  • task in increment , decrement , printf() , why these are evaluated in this manner in C
  • 28 extra bytes in bss
  • Waiting for multiple events without polling
  • Why are my variables reporting as "undeclared identifier" when compiling?
  • Correct AddNode function but somehing happens when I printf
  • When I traverse in the splay tree, then now which one is root?
  • Data type conversion in Postfix evaluation
  • No output in terminal (Head First C)
  • Data writes over after realloc
  • function: findnextchar() doesn't work
  • Getting file-size property from Nautilus
  • Forward declare entities in C standard library?
  • Static array in C
  • Function signature indicates return type void*, but returns pointer of a different type
  • How do I measure time per thread in C?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org