09-12-2008
Need help in character pointer
Hi,
I am trying to divide my input to different type of out puts for some other use.
ex: logical_name : jkl00001
expected out put : model=jkl and num=00001
here is the code i actually written
/*******************************************************************/
void update_new_logical_name(char *logical_name)
/**********************************************************************/
{
int next=0,ret=0,n;
char model[4];
int num[6];
char *name;
name=logical_name;
for(n=0;n<3;n++)
{
model[n]=name[n];
}
model[4]='\0';
for(n=3;n<8;n++)
{
num[n-3]=name[n];
}
num[6]='\0';
#ifdef DEBUG
printf("\n\nmodel== '%s',number=='%d'\n",model,num);
#endif
}
by using the above code i am not able to print anything .num displays some address and model displays nothing.
Some body please correct me
I need it urgently.
Thx,
jagan
10 More Discussions You Might Find Interesting
1. Programming
void main()
{
int a={1,2,3,4,5,6,7,8,9,10};
int *p=a;
int *q=&a;
cout<<q-p+1<<endl;
}
The output is 10, how?
if we give cout<<q it will print the address, value won't print....
if we give cout<<p it will print the address, value won't print....
p has the base addr; q... (1 Reply)
Discussion started by: sarwan
1 Replies
2. Programming
can u tell me the reson that why we should not delete a pointer twice.?
if we delete ponter twice then what happen and why this happen
Regards,
Amit (2 Replies)
Discussion started by: amitpansuria
2 Replies
3. Programming
what is far pointer in C (1 Reply)
Discussion started by: useless79
1 Replies
4. Programming
If one wants to get a start address of a array or a string or a block of memory via a function, there are at least two methods to achieve it:
(1) one is to pass a pointer-to-pointer parameter, like:
int my_malloc(int size, char **pmem)
{
*pmem=(char *)malloc(size);
if(*pmem==NULL)... (11 Replies)
Discussion started by: aaronwong
11 Replies
5. Programming
Can anyone tell me what the following statements do?
float (*tab);
tab=(float (*)) calloc(MAXCLASS,
(MAXCLASS+1)*sizeof(float)); (3 Replies)
Discussion started by: littleboyblu
3 Replies
6. Programming
Hi,
Can anyone tell me how i can declare and allocate dynamically an array of pointers to structured type?? Is declaration something like this:?
struct_name ** array; (1 Reply)
Discussion started by: littleboyblu
1 Replies
7. Programming
Hi guys, I'm trying to understand pointers in C and made a simple example and I've problems with It.
Can someone help?
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
int f1(char **str_);
int main(int argc, char **argv)
{
char *str = NULL;
f1(&str);
... (3 Replies)
Discussion started by: pharaoh
3 Replies
8. Programming
Does anyone know?
int x = 1;
int *p = &++x; //ok !
int *q = &x++; //gives an error :O
why the first pointer is ok but the second is an error? (13 Replies)
Discussion started by: nishrestha
13 Replies
9. Programming
Here are two programs that pass a pointer to a variable but behave differently. Shouldnt the i in second program be 0 after the function call?
#include<stdio.h>
void changeI(int *i)
{
*i = 10;
}
int main(void)
{
int i=5;
printf("%d before\n", i);
changeI(&i);
printf("%d... (1 Reply)
Discussion started by: dragonpoint
1 Replies
10. Programming
how to copy content of character pointer to character array in c programming..
char *num;
char name=num; (1 Reply)
Discussion started by: zinat
1 Replies
LEARN ABOUT OSX
rand_bytes
RAND_bytes(3) OpenSSL RAND_bytes(3)
NAME
RAND_bytes, RAND_pseudo_bytes - generate random data
SYNOPSIS
#include <openssl/rand.h>
int RAND_bytes(unsigned char *buf, int num);
int RAND_pseudo_bytes(unsigned char *buf, int num);
DESCRIPTION
RAND_bytes() puts num cryptographically strong pseudo-random bytes into buf. An error occurs if the PRNG has not been seeded with enough
randomness to ensure an unpredictable byte sequence.
RAND_pseudo_bytes() puts num pseudo-random bytes into buf. Pseudo-random byte sequences generated by RAND_pseudo_bytes() will be unique if
they are of sufficient length, but are not necessarily unpredictable. They can be used for non-cryptographic purposes and for certain
purposes in cryptographic protocols, but usually not for key generation etc.
The contents of buf is mixed into the entropy pool before retrieving the new pseudo-random bytes unless disabled at compile time (see FAQ).
RETURN VALUES
RAND_bytes() returns 1 on success, 0 otherwise. The error code can be obtained by ERR_get_error(3). RAND_pseudo_bytes() returns 1 if the
bytes generated are cryptographically strong, 0 otherwise. Both functions return -1 if they are not supported by the current RAND method.
SEE ALSO
rand(3), ERR_get_error(3), RAND_add(3)
HISTORY
RAND_bytes() is available in all versions of SSLeay and OpenSSL. It has a return value since OpenSSL 0.9.5. RAND_pseudo_bytes() was added
in OpenSSL 0.9.5.
50 2013-03-05 RAND_bytes(3)