Results 1 to 5 of 5
hi all
i have to write some script in c program
i tried this
Code:
//cc simple.c -o simple
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
char bb=system("cat ...
- 10-18-2007 #1Linux Newbie
- Join Date
- Feb 2007
- Location
- hyderabad, india
- Posts
- 247
c program help
hi all
i have to write some script in c program
i tried this
and the file.txt isCode://cc simple.c -o simple #include <stdio.h> #include <stdlib.h> #include <string.h> int main(void) { char bb=system("cat file.txt | sed -n '/Underlying Value/,/]Top/p' | egrep -v 'Underlying Value|]Top' | sed 's/\[[0-9]\{1,\}\]//g' > /home/munna/Desktop/munna.txt"); printf("******** %s \n",bb); return 0; }
but this program saying some errors like[1]Home > [2]F&O >
Watch
All contracts of NIFTY
As on Hours IST
Instrument Type Underlying Expiry Date Option Type High
Price Low Prev Close of contracts traded
Turnover Lakhs Underlying Value
[5]AAAAA [6]GGGGGG [7]25OC200 - - 5389.80 5203.10 5673.15 5255.00
89085 234115.83 5143.90
[8]AAAAA [9]GGGGGG [10]29NO2007 - - 5389.00 5211.00 5674.00 5269.95
5265 13869.14 5143.90
[11]BBBBBB [12]GGGGGG [13]25OC200 [14]CE [15]5600.00 74.00 15.00
168.60 34.05 810 2281.01 5143.90
[16]AAAAA [17]GGGGGG [18]27DE200 - - 5410.00 5125.00 5664.05 5265.00
694 1828.64 5143.90
[243]Top
[1]http://www.google.com/
[2]http://www.google.com/
[7]http://www.google.com/
[79]http://www.yahoo.com/
[2447]http://www.google.com/
[700]http://www.yahoo.com/
i wanna output in a string "bb".simple.c:9: warning: unknown escape sequence '\}'
simple.c:9: warning: unknown escape sequence '\]'
please help me
thank you in advance"Relationships are built on trust and communication"
- 10-18-2007 #2bb is an not an string array.Code:
char bb=system("cat file.txt | sed -n '/Underlying Value/,/]Top/p' | egrep -v 'Underlying Value|]Top' | sed 's/\[[0-9]\{1,\}\]//g' > /home/munna/Desktop/munna.txt");
Use string array.- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
- 10-18-2007 #3Linux Newbie
- Join Date
- Feb 2007
- Location
- hyderabad, india
- Posts
- 247
- 10-18-2007 #4
you are getting warning not an error so try with string array.
try adding another \ near { ...I'm not sure this is an root cause ,
Code:system("cat file.txt | sed -n '/Underlying Value/,/]Top/p' | egrep -v 'Underlying Value|]Top' | sed 's/\[[0-9]\\{1,\\}\\]//g' > /home/munna/Desktop/munna.txt");- Lakshmipathi.G
-------------------
FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
-------------------
- 10-18-2007 #5
I haven't tried to compile it, but your main problem is that system returns an exit status, not a string. If what you want is the contents of that output file to be inside your program, you'd run that system() then you would use fopen to open the file, and fread to get the contents into a character array.


Reply With Quote
