Sponsored Content
Full Discussion: K&R C code edits
Homework and Emergencies Homework & Coursework Questions K&R C code edits Post 302562884 by theexitwound on Saturday 8th of October 2011 08:04:57 PM
Old 10-08-2011
I work 40 hours a week, I'm doing what I can. It's not like I can just pick it up, read the man pages, a few examples, and know how to do it. I've tried hundreds of permutations of these expressions and it's just not easy to do. I've read back on the thread dozens of times and I'm doing my best with what I'm given.

---------- Post updated at 08:04 PM ---------- Previous update was at 07:04 PM ----------

Temp.txt:
Code:
double square(double value) {  double c; c = value * value; return c; } double square2(double value2) { double c2; c2 = value2 * value2; return c; }

I have it finding all end curly braces and adding a new line.
Then I have it successfully finding the first function and proceeding with the replacement.
However, it doesn't find the second function. Can't seem to figure out why.
Code:
cat temp.txt |  sed -e "s/\}/}\n/g; s/\([a-zA-Z][0-9a-zA-Z]\+ \+[a-zA-Z][0-9a-zA-Z]\+(\)\([a-zA-Z][0-9a-zA-Z]\+\) \+\([a-zA-Z][0-9a-zA-Z]\+\)) *\({.*}\)/\1\3)\2 \3\; \4/"

double square(value)double value; {  double c; c = value * value; return c; }
 double square2(double value2) {  double c2; c2 = value2 * value2; return c2; }

 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help with scripting mass file edits..

Hello, I am wanting to know a way to shell (ksh)script-edit a file by having a script that searches for a specific string, and then input lines of text in the file after that specific string. Please help, as I will be up all night if I can't figure this out. (16 Replies)
Discussion started by: LinuxRacr
16 Replies

2. Shell Programming and Scripting

Multiple edits to a bunch of html files

I'm trying to upgrade a whole bunch of pages on my site to a new design. I thought one way of doing it would be to enclose the content in special comment tags and then use some form of script to wrap the new html around it. Like this: <!-- content start --> <h1>Blah blah blah</h1> yada yada... (9 Replies)
Discussion started by: dheian
9 Replies

3. Shell Programming and Scripting

PHP read large string & split in multidimensional arrays & assign fieldnames & write into MYSQL

Hi, I hope the title does not scare people to look into this thread but it describes roughly what I'm trying to do. I need a solution in PHP. I'm a programming beginner, so it might be that the approach to solve this, might be easier to solve with an other approach of someone else, so if you... (0 Replies)
Discussion started by: lowmaster
0 Replies

4. UNIX for Dummies Questions & Answers

Compile & Run Java Code

The java program is a part of speech tagger -> The Stanford NLP (Natural Language Processing) Group The goal is to use this script as part of a webpage to tag parts of speech based on a user-inputted string. I have no idea what to do with the files - I'm a complete *nix noob. I tried running... (4 Replies)
Discussion started by: tguillea
4 Replies

5. UNIX for Dummies Questions & Answers

OpenLDAP DB_CONFIG edits, changes live? or do I need run something

So I am probably missing something , but when I made edits to my DB_CONFIG file to fix form db_lock issues, the changes are not propagating after a service restart. Anyone know if I need to run anything else, or are the changes live? (0 Replies)
Discussion started by: jcejka
0 Replies

6. Shell Programming and Scripting

Problem with call of Java Programm & return code handling & output to several streams.

Hello Everybody, thanks in advance for spending some time in my problem. My problem is this: I want to call a java-Programm out of my shell skript, check if die return code is right, and split the output to the normal output and into a file. The following code doesn't work right, because in... (2 Replies)
Discussion started by: danifunny
2 Replies

7. UNIX for Dummies Questions & Answers

multiple text edits inone pass

File_1 looks like: bunch of text Untitled Placemark bunch of text bunch of text Untitled Placemark bunch of text bunch of text Untitled Placemark bunch of text File_2 looks like: Title_001 Title_002 Title_003 First: I need to replace the 1st occurence of "Untitled Placemark"... (2 Replies)
Discussion started by: kenneth.mcbride
2 Replies

8. Shell Programming and Scripting

SFTP Shell Script Get & Delete && Upload & Delete

Hi All, Do you have any sample script, - auto get file from SFTP remote server and delete file in remove server after downloaded. - only download specify filename - auto upload file from local to SFTP remote server and delete local folder file after uploaded - only upload specify filename ... (3 Replies)
Discussion started by: weesiong
3 Replies
J0(3)							     Linux Programmer's Manual							     J0(3)

NAME
j0, j0f, j0l, j1, j1f, j1l, jn, jnf, jnl, y0, y0f, y0l, y1, y1f, y1l, yn, ynf, ynl - Bessel functions SYNOPSIS
#include <math.h> double j0(double x); double j1(double x); double jn(int n, double x); double y0(double x); double y1(double x); double yn(int n, double x); float j0f(float x); float j1f(float x); float jnf(int n, float x); float y0f(float x); float y1f(float x); float ynf(int n, float x); long double j0l(long double x); long double j1l(long double x); long double jnl(int n, long double x); long double y0l(long double x); long double y1l(long double x); long double ynl(int n, long double x); DESCRIPTION
The j0() and j1() functions return Bessel functions of x of the first kind of orders 0 and 1, respectively. The jn() function returns the Bessel function of x of the first kind of order n. The y0() and y1() functions return Bessel functions of x of the second kind of orders 0 and 1, respectively. The yn() function returns the Bessel function of x of the second kind of order n. For the functions y0(), y1() and yn(), the value of x must be positive. For negative values of x, these functions return -HUGE_VAL. The j0f() etc. and j0l() etc. functions are versions that take and return float and long double values, respectively. CONFORMING TO
The functions returning double conform to SVID 3, BSD 4.3, XPG4, POSIX 1003.1-2001. The other functions exist by analogy, and exist on sev- eral platforms. BUGS
There are errors of up to 2e-16 in the values returned by j0(), j1() and jn() for values of x between -8 and 8. 2002-08-25 J0(3)
All times are GMT -4. The time now is 04:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy