12-06-2008
Quote:
Originally Posted by
VRoemer
Make sure your files only have one extension with either of these solutions in the event you have files named like
myFile.tar.gz
my solution would work as it reads from the right.
myFile.tar.gz would return gz
10 More Discussions You Might Find Interesting
1. Programming
Hi,
char *s="yamaha";
cout<<s<<endl;
int *p;
int i=10;
p=&i;
cout<<p<<endl;
1) For the 1st "cout" we will get "yamaha" as output. That is we are getting "content of the address" for cout<<s.
2) But for integer "cout<<p" we are getting the "address only".
Please clarify how we are... (2 Replies)
Discussion started by: sweta
2 Replies
2. Shell Programming and Scripting
Hi,
How to replace any character in a file with a newline character using sed ..
Ex:
To replace ',' with newline
Input:
abcd,efgh,ijkl,mnop
Output:
abcd
efgh
ijkl
mnop
Thnx in advance.
Regards,
Sasidhar (5 Replies)
Discussion started by: mightysam
5 Replies
3. UNIX for Dummies Questions & Answers
I am writing a bash shell menu and would like to get a char immediately after a key is pressed. This script does not work but should give you an idea of what I am trying to do....
Thanks for the help
#! /bin/bash
ANSWER=""
echo -en "Choose item...\n"
until
do
$ANSWER = $STDIN
... (2 Replies)
Discussion started by: jwzumwalt
2 Replies
4. UNIX for Dummies Questions & Answers
I'm trying to run a script which will ssh to several other servers (All Solaris 10) and execute a sar -f command to get each server's CPU usage for a given hour.
It kinda works OK but I just can't figure out how to separate the returned fields with a Tab character. I've done lots of searching... (2 Replies)
Discussion started by: jake657
2 Replies
5. Programming
The below code throws the error, since the size of x = 19 is not passed to the cstrCopy function.
using namespace std;
static void cstrCopy(char *x, const char*y);
int main ()
{
char x;
const string y = "UNIX FORUM";
cstrCopy(x,y.c_str());
return 0;
}
void cstrCopy(char *x,... (3 Replies)
Discussion started by: SamRoj
3 Replies
6. Programming
i have an array like
#define NUM 8
....
new_socket_fd = accept(socket_fd, (struct sockaddr *) &cli_addr, &client_length);
char *items = {"one", "two", "three", "four", "five", "six", "seven", "eight"};
char *item_name_length = {"3", "3", "5", "4", "4", "3", "5", "5"};
... (1 Reply)
Discussion started by: omega666
1 Replies
7. Programming
Compiling xpp (The X Printing Panel) on SL6 (RHEL6 essentially):
xpp.cxx: In constructor ‘printFiles::printFiles(int, char**, int&)’:
xpp.cxx:200: error: invalid conversion from ‘const char*’ to ‘char*’
The same error with all c++ constructors - gcc 4.4.4.
If anyone can throw any light on... (8 Replies)
Discussion started by: GSO
8 Replies
8. Shell Programming and Scripting
Task 2:
When Im tring script called char that checks a single character on the
command line, c. If the character is a digit, digit is displayed. If the
character is an upper or lowercase alphabetic character, letter is
displayed. Otherwise, other is displayed. Have the script print an
error... (0 Replies)
Discussion started by: Roozo
0 Replies
9. Programming
Pointers are seeming to get the best of me and I get that error in my program.
Here is the code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define REPORTHEADING1 " Employee Pay Hours Gross Tax Net\n"
#define REPORTHEADING2 " Name ... (1 Reply)
Discussion started by: Plum
1 Replies
10. Programming
I am passing a char* to the function "reverse" and when I execute it with gdb I get:
Program received signal SIGSEGV, Segmentation fault.
0x000000000040083b in reverse (s=0x400b2b "hello") at pointersExample.c:72
72 *q = *p;
Attached is the source code.
I do not understand why... (9 Replies)
Discussion started by: jose_spain
9 Replies
LEARN ABOUT LINUX
encrypt_r
ENCRYPT(3) Linux Programmer's Manual ENCRYPT(3)
NAME
encrypt, setkey, encrypt_r, setkey_r - encrypt 64-bit messages
SYNOPSIS
#define _XOPEN_SOURCE
#include <unistd.h>
void encrypt(char block[64], int edflag);
#define _XOPEN_SOURCE
#include <stdlib.h>
void setkey(const char *key);
#define _GNU_SOURCE
#include <crypt.h>
void setkey_r(const char *key, struct crypt_data *data);
void encrypt_r(char *block, int edflag, struct crypt_data *data);
Each of these requires linking with -lcrypt.
DESCRIPTION
These functions encrypt and decrypt 64-bit messages. The setkey() function sets the key used by encrypt(). The key argument used here is
an array of 64 bytes, each of which has numerical value 1 or 0. The bytes key[n] where n=8*i-1 are ignored, so that the effective key
length is 56 bits.
The encrypt() function modifies the passed buffer, encoding if edflag is 0, and decoding if 1 is being passed. Like the key argument, also
block is a bit vector representation of the actual value that is encoded. The result is returned in that same vector.
These two functions are not reentrant, that is, the key data is kept in static storage. The functions setkey_r() and encrypt_r() are the
reentrant versions. They use the following structure to hold the key data:
struct crypt_data {
char keysched[16 * 8];
char sb0[32768];
char sb1[32768];
char sb2[32768];
char sb3[32768];
char crypt_3_buf[14];
char current_salt[2];
long int current_saltbits;
int direction;
int initialized;
};
Before calling setkey_r() set data->initialized to zero.
RETURN VALUE
These functions do not return any value.
ERRORS
Set errno to zero before calling the above functions. On success, it is unchanged.
ENOSYS The function is not provided. (For example because of former USA export restrictions.)
CONFORMING TO
The functions encrypt() and setkey() conform to SVr4, SUSv2, and POSIX.1-2001. The functions encrypt_r() and setkey_r() are GNU exten-
sions.
NOTES
In glibc 2.2 these functions use the DES algorithm.
EXAMPLE
You need to link with libcrypt to compile this example with glibc. To do useful work the key[] and txt[] arrays must be filled with a use-
ful bit pattern.
#define _XOPEN_SOURCE
#include <unistd.h>
#include <stdlib.h>
int
main(void)
{
char key[64]; /* bit pattern for key */
char txt[64]; /* bit pattern for messages */
setkey(key);
encrypt(txt, 0); /* encode */
encrypt(txt, 1); /* decode */
}
SEE ALSO
cbc_crypt(3), crypt(3), ecb_crypt(3), feature_test_macros(7)
COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
2003-04-04 ENCRYPT(3)