Sponsored Content
Top Forums Programming Some error with number of keyboard inputs occured with this code for reversing a string.. Post 302535079 by shamrock on Wednesday 29th of June 2011 03:08:04 PM
Old 06-29-2011
The malloc function is declared in stdlib.h not malloc.h...and scanf with %c wont skip over whitespace like the newlines that get carried over during input.
This User Gave Thanks to shamrock For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reversing and trim a String through SHELL script

All I want to reverse and trim a string using UNIX shell scripts.Iam using Bourne shells. Can you help me? Thanx in advance Regards Deepak (5 Replies)
Discussion started by: DeepakXavier
5 Replies

2. Shell Programming and Scripting

output string in reversing order

If I have string { I_love_shell_scripts} anyone knows how to have output {stpircs_llehs_evol_I} by using shell and perl ?I know in perl, there is reverse() funcation, but can it be done by not using reverse()? (3 Replies)
Discussion started by: ccp
3 Replies

3. Shell Programming and Scripting

read n number of inputs

Hello, I think its a sinple query but somehow i m stucked up here... I am trying to enter n number of inputs from the user and write them in an input file ie row wise... I tried standard commands like $echo "enter the inputs for the file" $read var1 var2 var3 var4 test1 test2... (14 Replies)
Discussion started by: er_aparna
14 Replies

4. UNIX for Dummies Questions & Answers

Help how replace stardard keyboard inputs by arguments at run time of a script

Hello Everybody, Please help. I was trying to automate the use of a third-party given shell script. The script is written to be used at run-time to collect a few variables to be provided by the user through key board, in the fashion as below: ./runcommand please provide a file name to... (6 Replies)
Discussion started by: Dingrong
6 Replies

5. Shell Programming and Scripting

reading and reversing a string

Hi Everyone....I am new to Unix and BASH programming...I just want to read a string and reverse it and display.....can anyone help me out???? (8 Replies)
Discussion started by: nikhilneela
8 Replies

6. Shell Programming and Scripting

Need help reversing this code

ssh servername.com "echo /$APP=$BUSIN >> $URI; echo /$APP/*=$BUSIN >> $URI" Ok for example here i ssh into a example servername.com, and I think what it does some line gets put into the urifile , my question is, how would i go about removing that in a script. in summary, the above code is... (3 Replies)
Discussion started by: new2learn09
3 Replies

7. UNIX for Advanced & Expert Users

Error occured while running a script

Hi All, In my application, I'm getting an error as type mismatch Let me now explain the scenario, I ran a shell script which calls some other scripts. All these scripts uses the environment variables. Take for example, this script uses a variable 'PathDir'. I initiallized the value to... (2 Replies)
Discussion started by: iamgeethuj
2 Replies

8. UNIX for Dummies Questions & Answers

Newbie Alert:Reversing part of a string?

Hello all, Wondering if anyone can help me out. Trying to cut the names out of the /etc/passwd file so that they can be displayed first then last name. I cut them out and put them into variables but cant get them to display side by side after cutting. Anyone able to help a newbie? (1 Reply)
Discussion started by: losingit
1 Replies

9. Shell Programming and Scripting

Automation of keyboard inputs..like Ctrl+d and Ctrl+a

Hi..! I'm stuck with my automation of starting a process and keeping it running even after the current ssh session has exited.. So i'm trying to use command 'screen'. which is doing exactly what i wanted, But the problem is automation of the same. i will have to press Ctrl+a and Ctrl+d for... (2 Replies)
Discussion started by: chandana hs
2 Replies

10. UNIX for Dummies Questions & Answers

How to send keyboard inputs toa UNIX command executed from a shell script?

I have a unix command that prompts for 'y'. How do I run this from my shell script? (4 Replies)
Discussion started by: Sree10
4 Replies
POSIX_MEMALIGN(3)					     Linux Programmer's Manual						 POSIX_MEMALIGN(3)

NAME
posix_memalign, memalign, valloc - Allocate aligned memory SYNOPSIS
#include <stdlib.h> int posix_memalign(void **memptr, size_t alignment, size_t size); #include <malloc.h> void *valloc(size_t size); void *memalign(size_t boundary, size_t size); Feature Test Macro Requirements for glibc (see feature_test_macros(7)): posix_memalign(): _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 valloc(): Since glibc 2.12: _BSD_SOURCE || (_XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) && !(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) Before glibc 2.12: _BSD_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED DESCRIPTION
The function posix_memalign() allocates size bytes and places the address of the allocated memory in *memptr. The address of the allocated memory will be a multiple of alignment, which must be a power of two and a multiple of sizeof(void *). If size is 0, then posix_memalign() returns either NULL, or a unique pointer value that can later be successfully passed to free(). The obsolete function memalign() allocates size bytes and returns a pointer to the allocated memory. The memory address will be a multiple of boundary, which must be a power of two. The obsolete function valloc() allocates size bytes and returns a pointer to the allocated memory. The memory address will be a multiple of the page size. It is equivalent to memalign(sysconf(_SC_PAGESIZE),size). For all three routines, the memory is not zeroed. RETURN VALUE
memalign() and valloc() return the pointer to the allocated memory, or NULL if the request fails. posix_memalign() returns zero on success, or one of the error values listed in the next section on failure. Note that errno is not set. ERRORS
EINVAL The alignment argument was not a power of two, or was not a multiple of sizeof(void *). ENOMEM There was insufficient memory to fulfill the allocation request. VERSIONS
The functions memalign() and valloc() have been available in all Linux libc libraries. The function posix_memalign() is available since glibc 2.1.91. CONFORMING TO
The function valloc() appeared in 3.0BSD. It is documented as being obsolete in 4.3BSD, and as legacy in SUSv2. It does not appear in POSIX.1-2001. The function memalign() appears in SunOS 4.1.3 but not in 4.4BSD. The function posix_memalign() comes from POSIX.1d. Headers Everybody agrees that posix_memalign() is declared in <stdlib.h>. On some systems memalign() is declared in <stdlib.h> instead of <malloc.h>. According to SUSv2, valloc() is declared in <stdlib.h>. Libc4,5 and glibc declare it in <malloc.h> and perhaps also in <stdlib.h> (namely, if _GNU_SOURCE is defined, or _BSD_SOURCE is defined, or, for glibc, if _XOPEN_SOURCE_EXTENDED is defined, or, equivalently, _XOPEN_SOURCE is defined to a value not less than 500). NOTES
On many systems there are alignment restrictions, for example, on buffers used for direct block device I/O. POSIX specifies the path- conf(path,_PC_REC_XFER_ALIGN) call that tells what alignment is needed. Now one can use posix_memalign() to satisfy this requirement. posix_memalign() verifies that alignment matches the requirements detailed above. memalign() may not check that the boundary argument is correct. POSIX requires that memory obtained from posix_memalign() can be freed using free(3). Some systems provide no way to reclaim memory allo- cated with memalign() or valloc() (because one can only pass to free(3) a pointer gotten from malloc(3), while, for example, memalign() would call malloc(3) and then align the obtained value). The glibc implementation allows memory obtained from any of these three routines to be reclaimed with free(3). The glibc malloc(3) always returns 8-byte aligned memory addresses, so these routines are only needed if you require larger alignment val- ues. SEE ALSO
brk(2), getpagesize(2), free(3), malloc(3) 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/. GNU
2010-09-20 POSIX_MEMALIGN(3)
All times are GMT -4. The time now is 03:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy