Programming :: Append Item To A List ( C Macro )?
Apr 13, 2010
I have my own declared types and I have to operate with lists of items. I wish to write a one macro, instead of using a function for each type. It's intended to be like this: Code: #define ____append_to_list(head,
item, type)
type* ptr;
for ( ptr = head; ptr->next != NULL; ptr = ptr->next )
[code].....
View 9 Replies
ADVERTISEMENT
Dec 30, 2010
If I do:
for i in $(cat names); do seq -f "$i%03.0f" 0 999; done > output5.txt
I got ( tail snipped):
997munt
998munt
999munt
If I do:
for i in $(cat names); do seq -f "%03.0f$i" 0 999; done > output4.txt
I got:
997Zygmunt
998Zygmunt
999Zygmunt
How I can get numbers from 000 to 999 appended like:
Zygmunt997
Zygmunt998
Zygmunt999
View 8 Replies
View Related
Mar 24, 2011
How to list all the files that don't contain pattern1 and append a new line (pattern1) to those files before pattern2 only once.
pattern1 = /var/script/showMessage.sh
pattern2 = ;;
Code:
grep -c 'pattern1' /var/script/*_cam* | grep :0 | add pattern1 before pattern2 in each file loacted before.
View 10 Replies
View Related
Jul 14, 2010
I was reading some code the other day and thought that I saw they were using the list.pop method to pop of more than one item at a time. Something like this.
Code:
l = [ 'a', 'b', 'c', 'd', 'e' ]
l.pop(0:3)
['a','b','c']
l
['d','e']
But of course when I looked at invoking the method, it only works for one item at a time. I'm working on a data structure where I'm parcing weather data that is 15 items long that are return in as data in a list that has 3,000 + items. I was wanting to pop off a lists of the 1st 15 items breaking them into chuncks (still trying to figure out how I'm going to store the associations as each day has 2-4 readings an hour for the past 72 hours, so I was wanting to group the days together but have each data point for each time).
I know I can just write a function (with some additional tweaking needed for neg starts to work on the right end):
Code:
def longpop (seq, length=1, start=0):
slice = seq[start:start+length]
del seq[start:start+length]
return slice
But with increasing data sizes, I was wondering if there was a faster built-in way of doing this (perhaps implemented under the hood written originally in C as an extention, for example).
View 6 Replies
View Related
Nov 27, 2010
Recently I have installed DockbarX and Cardapio. After installation they are supposed to be found in the Add to Panel items, but both of them are not there.I can run them directly without any problem. Is there anything else I should do manually? I have tried pkill gnome-panel to restart the panel as well.
View 9 Replies
View Related
Feb 9, 2011
I am using the package Quantum espresso to get electron phonon coefficients for monolayer graphene. While applying one of the executables, I got the error: "At line 356 of file q2r.f90 (Unit 51 "a2Fq2r.51") Traceback not availabel: compile with -ftrace=frame or -ftrace=full. Fortran Runtime error: bad real number in item 1 of list input
View 3 Replies
View Related
Dec 12, 2009
I converted my programming project over to autotools, which gives me a config.h file with all the cool definitions, like these ones:
Code:
/* Location of data files. */
#define DATADIR "/usr/local/share"
/* Define to the full name of this package. */
#define PACKAGE_NAME "lusus"
And naturally I think this is cool because then I can hardcore these into the binary. To my dismay, however, I discovered that the pre-processor does not do the text-substitution if the macro name is inside another quoted string.
Code:
// Prints out "/usr/local/share/lusus"
std::cout << DATADIR << "/" << PACKAGE_NAME << "
";
[code]....
This seems lame, because then this doesn't work:
Code:
CL_Image leaves_corner_tl(gc, "DATADIR/PACKAGE_NAME/img/leaves_corner_tl.png");
So, am I literally going to have to strcat DATADIR/PACKAGE with the other text every time I want to prefix DATADIR/PACKAGE_NAME onto another string?
View 2 Replies
View Related
Mar 20, 2011
I've been reviewing some source code recently which contains many conditional compilation statements, and I found it hard to understand the code not knowing whether some macro is defined or not. Is there any way to test whether a macro is defined?
View 2 Replies
View Related
Aug 18, 2010
All I'm trying to do is ShellExecute a program every time a new slide appears.
I'm using Office 2003 Powerpoint.
I did the following:
1. Tools, Options, Security Options, Macro Security, Security Level= Medium
2. Tools, Options, Macro, VBA Editor:
Code:
Sub OnSlideShowPageChange(ByVal SSW As SlideShowWindow)
MsgBox ("OnSlideShowPageChange")
End Sub
3. File, Save
4. Back to PowerPoint: F5) Slide Show, View Show <= Did NOT see the message box
5. Exit out of Powerpoint, reopen the .ppt file, F5) again <= Still don't see the message box
why isn't "OnSlideShowPageChange" getting invoked when I run the slide show?
View 3 Replies
View Related
Dec 3, 2010
integrate a macro from MS Word to Open Office? It is a script I need for music. I cannot upload the file here nor give you the link, because I'm not let.
View 9 Replies
View Related
Jan 29, 2011
telling the exact macro name and location, by which I can gain control over the following kernel base level structure
1. strct super_block of Virtual File System, for super block object.
2. strct inode for inode ofject of VFS.
3 file structure for file object of VFS.
in addition to these if you know location to access other kernel structure.Please let me know.My main objective is to get the access to the structure pointer of these structure by which i can have access over the individual fields o these structure.
View 11 Replies
View Related
Nov 21, 2010
I am trying to understand working of pci_resource_start function So I browsed code via cscope and searched for string pci_resource_start and got following in pci.h
Code:
#define pci_resource_start(dev, bar) ((dev)->resource[(bar)].start)
I am not able to understand how does this above macro works. How does it above macro gets appropriate base address register in configuration space?
View 1 Replies
View Related
Jun 27, 2009
I am dealing with some Linux kernel code, which define most its functions with Macros.The trouble I am having is to use those code in user space in Windows.
For example, I have a function defined like this:
#define list_for_each_entry_safe(pos, n, head, member)
for (pos = list_entry((head)->next, typeid(*pos), member),
n = list_entry(pos->member.next, typeid(*pos), member);
&pos->member != (head);
pos = n, n = list_entry(n->member.next, typeid(*n), member))
And in user space code, I call it in this way:
list_for_each_entry_safe( pcre_item, tmp,
&(((pcre_list_head_t *)(hr.value))->head), list)
{
// My code to handle each element in the list
}
This is working like a charm in Linux, but I got errors in Windows:
It reminds me missing ';' after 'list_for_each_entry_safe( pcre_item, tmp,
&(((pcre_list_head_t *)(hr.value))->head), list)'.
Does this kind of linux code not working in Windows at all? (Linux is in GCC C stand and VC is ANSI C) I prefer not to convert them to normal functions but keep it the way if it could be working under windows by some tricks.
View 5 Replies
View Related
Aug 10, 2010
The s means substitute
The $ in this particular regex (regular expression) means end of the line.
The ; is what you're subbing. This works fine and well, but what if you want to append a / at the end of the line?
sed 's/$///' filename doesn't work.
View 1 Replies
View Related
Sep 20, 2009
I'm having problems completing my school exercises with awk.
Heres the desired outcome:
Code:
./my_awk 2
ACG GAG ATT AGG AGG ATC CCA CCA
CAC AGG ACG GAG ATT AGG AGG ATC
So it generates data in group of threes, 8 groups per row and prints it. My problem is that I can't seem to get awk to append stuff to string so I could print it nicely to screen. It just prints empty lines per the parameter given to it.
Heres my code so far:
Code:
#!/bin/sh
awk -v rows=$1 '
BEGIN {
[code]....
View 2 Replies
View Related
Jan 29, 2011
What I am trying to achive is the editing of /etc/ssh/sshd_config I have the line
Code: AllowUsers usera userb
And I want to be able to append to the end of this line from a bash script.I have muddled together from other sites and got the following:-
Code: sed -e "s/^AllowUsers/� userc/" -i /etc/ssh/sshd_config
But this appears to add userc directly after AllowUsers and not after userb
View 2 Replies
View Related
Sep 29, 2010
I have the following command that works Code: ssh root{at}IPADDRESS 'vim-cmd vmsvc/power.getstate 64 | grep Powered | awk "{ print $2}"' Which outputs the following text:- Powered on I would like to Append some text so the output is:- Ubuntu Server: Powered on Every different variation that I have tried ends up in an unexpected token.
View 1 Replies
View Related
Apr 9, 2010
I have a requirement like this..this just a sample script...
Code:
when i run this scipt...
Code:
Code:
It is appended in the same line...
I want it to be added to the next line.....
I want to do this by explitly using the filehandles in perl....and not with redirection operators in shell.
View 1 Replies
View Related
Nov 6, 2010
Say I have a text file like:
Code:
1
3
4
How would I use ksh to put the number '2' into the second line of that file?Okay it's not bash, it's ksh because this computer is OpenBSD
View 14 Replies
View Related
Jan 14, 2010
I am trying to append text to the beginning of a file. This is what I have so far.
Code:
date_default_timezone_set('America/Chicago');
$date=date("m-d-Y g:i:s a");
[code]....
View 7 Replies
View Related
Apr 6, 2010
where I'm trying to demonstrate the file locking concept through Perl/CGI.Here is the script which I tried.
Code:
#!/usr/bin/perl -w
use strict;
use warnings;
print "Content-type: text/html
[Code].....
View 2 Replies
View Related
May 19, 2011
I have the following function that does not iterate through the array I want to be able to do some manipulation on each element in the array[@].it appears the below array has only one item in the array whereas i want the array to have 3 items hence the loop three times printing the message Any ideas why this is not happening ?
function foo() {
name =$1
array=( "$2" )
[code]...
View 5 Replies
View Related
Apr 15, 2009
I am thinking of appending something to each line in a text file with Java. I prefer not write a new file with content appended from the old one.That 'something' would probably be Time Stamp when the file is created (which is same for each line).I am not sure Java provide some easy way for it or not
View 3 Replies
View Related
Mar 16, 2010
So I have file which looks something like this:
cat .opera/operaprefs.ini
Code:
[User Prefs]
Language Files Directory=
[code]...
View 1 Replies
View Related
Jun 8, 2010
I want to append a variable string to the end of a specific line. not like append the same string to each line. like in my file i have 4 columns, i want to add a string in 5th column in some fixed row.
View 4 Replies
View Related
Nov 28, 2010
Is it possible to have an array in Bash that can hold more than one value per item?
For example I would like an array like this:
Entry 1: apple, green
Entry 2: banana, yellow
And be able to call the fruit names and their colour in a list. Something like:
for fruit in "${array[@]}"
do
echo a $fruit is $colour
done
If that is possible, is there a limit to values per item? For example some entries in an array could be:
Entry 1: apple, green, round, pips, tree
Entry 2: banana, yellow, long, skin, tree
And I would like to pick out the values such as #3 being "round" and "long".
View 3 Replies
View Related
May 4, 2011
I need to make a quick gui to interface with another application. I'm using Java swing to produce it, however have no experience with JAVA. I have used net bean to produce the gui. At one part I have a jList private javax.swing.JList jSymbolList1;
I want on a button press to add or change members of the list from a text field. I thought I could so this simply by using the addelement eg jSymbolList1.addElement("hello world"); However this produces an error. Can anyone tell me how to add a string or how to change a string at a set position?
View 4 Replies
View Related
Sep 17, 2010
I recently was pointed to [URL] in another thread and ran into a problem: What header file do I need to download to write the code in the documentation? Apparently no 'bignum.h' file on the Internet declares the "BN_ULONG" macro or "BN_BITS2" bit chunks.
View 1 Replies
View Related
Feb 2, 2010
How would I list 4 users ID numbered 10, 11, 12 and 13 from my users list and output them to a file busers where their names are numbered by ascending order? How would I accomplish that on a one line command?
View 4 Replies
View Related
Feb 10, 2009
I am trying to get this script to work. The purpose is to download a list of modules from the slax.org the list consist of a list of module numbers. What I am trying to do is Download the file or the file name corresponding to the number in the list.the list is comma delimited. this is what I have done so far and I am a stand still.
#!/bin/sh
# Wget script to retrieve modules from slax.org modules
#
# ----Begin of user defined values -----
# Path to wget
[code].....
View 7 Replies
View Related