Programming :: C - Check If An Input Char Contain Numbers?

Mar 19, 2010

I would like to create a small C tool. I encounter a problem of how to make a function to check an input chars contains numbers (started from the second element).

Some samples:

char *mychar= "a3547"; (The result of function checking this is true)
char *another_char = "t6548"; (The result of function checking this is true)
char *next_char = "appl3"; (The result of function checking this is false)
char *new_char = "b1aa3"; (The result of function checking this is false)

View 4 Replies


ADVERTISEMENT

Programming :: Make A Script That Checks Input Letters / Numbers?

May 19, 2010

I would like to know how to make a script that can check that i input 3 letters and 3 numbers in some field.

i am completely noob in this programming scene, but think its quite interesting.

View 13 Replies View Related

Programming :: Multiple Input Into Seq Command From Pipe - Single Column Unique Numbers

May 13, 2011

Have this script which is reading in a series of files, one at a time with while-do-done loop, each file goes through various greps/awk's where this info is then saved to various files for later use. i.e....

Script is being run on Linux Red Hat,

In one of the grep/awk's the output (currently) are 2 columns (min max), i.e....| awk '{print $1, $2}' | sort -u which outputs (e.g.)

The number of "min max" pairs varies from file to file. Want to output a single column of unique numbers from the min max pairs & get the number of them for input to a file...i.e...

Where <PROCESS> is some process/technique that will generate a single column of integers (increment of 1) to pipe into the next one (sort -u)

i.e. (example from above)

Have tried command seq - only works for single pair input i.e.

Is there any command like seq etc which will output a single column based on a input of min max numbers (increment 1) to pipe onwards to next command?

View 4 Replies View Related

Programming :: Fixing C++ Invalid Conversion From Const Char* To Char?

Mar 4, 2010

m getting the following error when trying to compile:Quote:

$ make
g++ -march=athlon64 -O2 -pipe -fomit-frame-pointer -msse3 -c -D_GNU_SOURCE -DPLUGIN_NAME_I18N='"undelete"' -DHAVE_SVDRP -I../../../include undelete.c

[code]...

View 14 Replies View Related

Programming :: Point A Char Pointer To A Part Of Another Char Array?

Nov 4, 2010

Programming in C.I have two char arrays.char buf1[1024];char buf2[1024];Aren't buf1 and buf2 also pointers?I read in 1024 bytes into buf1 which contain about 300 bytes of characters with newlines. The data is basically a few English sentences. I'm trying to scan buf1 for newlines and then stop at the 1st newline and copy the rest of the data from that 1st newline into buf2.So I run a for loop to look for that new line.

Code:
for(i=0; i<1024;i++) {
if((strcmp(&buf1[i], "

[code]...

View 8 Replies View Related

Programming :: C++ Invalid Conversion From Const Char* To Char*

Jul 9, 2010

I am having trouble with the following exception class.

Code:

/**Standard Exception
*
*@description
*@update
*@changes

[code]....

Line 43 points at the snprintf() command.I think the error has to do with the function being virtual and the const after the function definition, however although I have been looking really hard I have not being able to find the reason nor the solution to the problem.

One workaround that I know is moving the block of source withing the virtual function, in the constructor, however having read around (boost library exceptions tutorials) it specifically said that formating of errors messages should not take place withing the construction of objects because we are risking throwing an exceptions and messing up the flow order.

View 11 Replies View Related

Programming :: Char Variable Is Behaving As Unsigned Char?

Feb 14, 2011

i define variable of type char (range -128 to 127). when i tried to print the value after assigning a -ve value to it it displaying a +ve value of that -ve value(256+value).

View 3 Replies View Related

Programming :: SH: Remove Last Char If It Is An Empty Char In A String

Jul 5, 2011

With this I may remove the last emtpy char which is not visible, coming from net, windows, ...

Code:
echo "$mystringwindowsorotherwithemptylastchar" |sed s/.$//

However if there are not then it makes a problem and delete effectively an existing char.

Code:
echo "klklj" |sed s/.$//
klkl

Anyone would have a solution for SH?

View 2 Replies View Related

Programming :: Convert A Char * To Unsigned Char?

Mar 4, 2010

is it possible to convert a variable from char * to unsigned char ?

View 5 Replies View Related

Debian Programming :: Check If Files Exists By Read Input From A File

Jul 27, 2013

I need a script that dose the following checks if files exists by read input from a file then compares them to the files listed in the directory if they don’t exists the script would report back which file dose not exists. I also need to format the output so that files are grouped in different groups, group A, B, and C and etc based on file name. I would like the output of that do not exists files to be sorted based on second number in the file name than group according. I understand some of the basics of bash scripting something along of the lines of a loop and if statements might do the trick. Below is what I have so far. I don’t car so much about the script reporting back the file exists I prefer to only know if the file is missing and is less than 3 days old. Problem is if a file dose not exists in the reports file the test compares against the wrong file.

Group A

Foo22000.tar.gz
Foo22010.tar.gz

Group B

foo25000.tar.gz
foo25100.tar.gz

Group C

foo26000.tar.gz

Code] ....

View 2 Replies View Related

Programming :: Make The Program Check If Either On Of The Input (either $Title Or $Author) Is Not Filled Up

Jan 11, 2010

Title : Author : Price
France : Mark : 40
Persia : John : 50

how i arranged my database. I am trying to write aprogram which does a search either using Title, Author or both.

[Code]....

but i am still unclear on how i am able to make the program check if either on of the input(either $Title or $Author) is not filled up, and if one of it is not filled up, use the other one which is filled to do a search.

View 6 Replies View Related

Software :: Bash Input Control - Different Numbers ?

Mar 18, 2011

I'm making an bash script.

As input you can input different numbers from 1 to 3.

Depending from the input a text shows up.

View 2 Replies View Related

Programming :: Programing - Reading File Line By Line Then Char By Char In Each Line

May 29, 2010

I've never programed shell scripting.

Code goes like so:

I simply want to read a file "data.txt" line by line Then char by char and add them into a result var. The file is supossed to always contain numeric values

View 8 Replies View Related

Fedora :: Vpnc Not Connecting / Error Can't Open /dev/net/tun, Check That It Is Either Device Char?

May 30, 2011

i need to install vpnc in amazon ec2 fedor 8 instance. i have installed with yum install vpnc commaned. And i have placed config file in /etc/vpnc/some.conf. but it is not connecting and giving the following error.
vpnc: can't open /dev/net/tun, check that it is either device char 10 200 or (with DevFS) a symlink to ../misc/net/tun (not misc/net/tun): No such device.

View 6 Replies View Related

Programming :: Create Inverted Files To Associate Files To Numbers ( Numbers Being The Index Of My Paths )?

Apr 4, 2011

am writing a small search program for my class. I have decided to use indexing for my program. Ive researched online about indexing and how search engines do it. If im gonno do that I need to create inverted files to associate files to numbers ( numbers being the index of my paths ) . Now I was wondering what would be the best way to create an inverted file ? I was going to create sql tables using mysql api in C but then again there is no array data type or vectors to store few numbers in a single column in mysql and it is not advised to use Enum or SET

View 14 Replies View Related

Programming :: Cannot Get Ncurses To Delete Char With

Jan 6, 2010

I've modified a program to show * instead of letters when typing a password. I'm trying to make it so that when pressing backspace a * will be removed.Here's a rough example. The problem is that when trying to do this in the real program,' is not recognized as backspace.

View 6 Replies View Related

Programming :: GMP And Converting Mpz_t To Char?

Jul 16, 2011

I'm writing the Diffie-Hellman key exchange system using GMP to handle big integers. For the most part, everything works. I can convert the string to mpz_t, set up the keys and everything, and encrypt it fine. Its the decrypting I'm having issues with. What I'm using is mpz_xor() for both. To encrypt I'm doing mpz_xor(buffer, mpz_of_text, secret_key), and to decrypt I'm doing mpz_xor(buffer, mpz_of_cipher, secret_key).

For one character, it semi-works...it'll decrypt it fine, but it'll return it as it's ASCII value (i.e.: if I encrypt "A", it'll decrypt it as 65). Which, I can easily just do sprintf(decrypted_buffer, "%c", 65) for example and be fine. But, when I'm sending text bigger than one character, the encryption for AB gives me something like 1061043 after running the decrypting xor on it.

Has anyone ever done this before or can point me in some directions? Perhaps other algorithms to try? I know XOR isn't the most secure encryption method to use, but at the time I wasn't sure what else to use. I'm really just having a hard time trying to convert a mpz_t to a character string. I've looked at mpz_get_str() and it works before running encryption (i.e.: using mpz_set_str() to create a mpz of a string, then calling mpz_get_str() to change it back). Maybe my XOR method is wrong? Here's the code I'm using:

Code:

/**
* str2mpz()
* b The current buffer of text to convert [in]
* m The mpz_t variable to store converted text [out]

[code]....

View 9 Replies View Related

Programming :: Get The Number Of Elements In A Char*[] In C++?

Jan 27, 2011

I have a char*[] array:

Code:
char* myarray[] = {"Hello", "there!", "LQ"};

and I wish to use/ write a function to find the number of elements in myarray (in this case, its 3).

*equivalent of .NET's array.size() that returns number of elements in array

How do I achieve it?

View 7 Replies View Related

Programming :: Passing A Char* By Reference In C++?

Apr 26, 2010

Below I've presented the declaration, definition and the calling method of a function w.r.t pass by reference:

Declaration

Code:

void getUnpackedMsg (unsigned char &data, unsigned int numberOfBits);
Definition
line 278: Shown in RED

Code:

void packedMessage :: getUnpackedMsg (unsigned char &emptyArray, unsigned int numberOfBits)
{
...
...
printf ("

[code].....

View 3 Replies View Related

Programming :: Vi - Deleting Up To First Nonblank Char?

Jul 18, 2010

What could be a command to erase from the cursor up to the first non-blank char in vi (or vim)?

View 3 Replies View Related

Programming :: Passing The Char * Vector Argument?

Jun 19, 2010

I am trying to simulate a shell. So what I do is checking of having the parameters from standard input, suc as "/bin/ls -l /home/france/Documents", and then passing them to function execute, which at some point calls execvp(argv[0],argv)The problem is that I don't succeed in using these arguments, while if I call execvp(paramList[0],paramList) it works!!!! Where paramList is exactly what I would put on standard input, but defined statically.

Code:

#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

[code].....

View 2 Replies View Related

Programming :: Copying Unsigned Char To Uint64_t?

Oct 17, 2010

I am a dummy in C programming. I have a problem with copying the array of 64 elements of unsigned char to array of 8 element of uint64_t. For example:

unsigned char p[64]
uint64_t Data[8];
memcpy (&Data, &p, 64);

I am not sure if it is right. Please help me. Thanks a lot.Moreover, do both p and Data have 64 bytes?

View 2 Replies View Related

Programming :: C Define Char* Array With Calloc?

Mar 6, 2011

This works for "char" but i need "char*",how do I do it?

Code:

char* tk = (char*) calloc(ctk+1,sizeof(char*));

Error when I use it:

Code:

error: invalid conversion from har* to har

View 2 Replies View Related

Programming :: How To Convert Wide Char Data?

Jul 15, 2010

Can anyone please suggest me how can we convert a wide char data in linux which is of 32 bit to a 16bit data. I have a file which has 16bit binary data? Could any one please give me ideas.

View 2 Replies View Related

Programming :: How To Remove Alternate Char From File

Jan 19, 2010

How to remove alternate char from file using shell script? If the file content is "1234567890" the output file should be "24680".
sed 's/(.)(.)/2/g' filename
Now there may be small modification to generate two alternate byte, what it should be? If the file content is "1234567890" the output file should be "125689".

View 4 Replies View Related

Programming :: Search And Repalce A Char In Path Using Sed ?

Sep 1, 2009

I have the following path wher i want to replace forward slashes with back slashes using sed path=/temp/file.tar

I am using the following but it's not working.

View 3 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 :: C Function Not Returning An Integer After Comparing It To A Char?

Jan 23, 2010

I've got a strange bug that I cannot figure out how to solve. Here is the function.

Code:
int getnexttab(char input[], int index, int length)
{

[code]....

View 14 Replies View Related

Programming :: C String As An Array Of Chars And As A Pointer To Char?

May 13, 2009

Please look at the comments

Code:
/*
* TEST CASE TO CHECK DIFFERENCES BETWEEN STRING AS

[code]...

View 14 Replies View Related

Programming :: Pass A Char* Array As A Function Paramter In C++?

Jan 27, 2011

I have the following char* array

Code:
char* chrarray[] = {"Hello","LinuxQuestions"};
and I need to pass it into a function, how should I define my function in the header file?

[code]....

View 3 Replies View Related







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