[off topic slightly]
If you're on a unix box (I can't tell positively), all of this is a done deal -written long ago.
sed, grep, and maybe awk are your friends.
[/off topic slightly]
[off topic slightly]
If you're on a unix box (I can't tell positively), all of this is a done deal -written long ago.
sed, grep, and maybe awk are your friends.
[/off topic slightly]
Please help: I am unable to run a C Program which I have written as an extension of an earlier simple program. I believe it has to do with an object file clash which I am not able to resolve. Here is the source code for my program:
/* opens and extracts text from a file */
#include <stdio.h>
#include <string.h>
#include "tfdef.h"
#include "strdef.h"
#define MAXSIZE 5000
int main()
{ FILE *ifp, *ofp; /* ifp is input file pointer & ofp is output file pointer */
char month[MAXSIZE];
char cmonth[MAXSIZE]; /* clearance month */
char cdate[] = ""; /* clearance month using format YYYYMM */
ifp = fopen("form2.txt", "r"); /* open "form1.txt" for reading by assigning to ifp */
if(ifp==NULL) {
printf("Error: can't open file form1.txt.\n");
exit(0);
}
else {
printf("Input file opened successfully.\n");
}
ofp = fopen("outfile1.txt" , "w"); /* open file for output */
if(ofp==NULL) {
printf("Error: can't open file for output.\n");
exit(0);
}
else {
printf("Output file opened successfully .\n");
}
/* Here need to write function that when control string is recognized it
creates its numeral equivalent and writes it to the ouput file - 13
cases for control month: December 2004 to December 2005 */
while (fgets(cmonth, MAXSIZE - 1, ifp))
if(month == "December 2004"){
if(srchstr(cmonth,month)) {
cdate[1] = "200412";
}
}
else
if(month == "January 2005") {
if(srchstr(cmonth,month)) {
cdate[1] = "200501";
}
fputs(cdate, ofp);
fclose(ifp);
fclose(ofp);
}
int srchstr(STRING s, STRING str)
{
while (*s)
if (compare(s, str)) /* if str is at the start of s */
return TRUE; /* return TRUE */
else s++; /* otherwise, go to the next position */
return FALSE; /* string exhausted, return FALSE */
}
int compare(STRING s, STRING str)
{
while(*str)
if (*str++ != *s++)
return FALSE;
return TRUE;
}
}
==============================================
Compiling the file I specify readfile as the object file. I enter the following prompt command:
$ gcc -Wall rfile.c -o readfile
The attached file gcc_compile shows the results of compilation. I then execute the object file by entering the command:
$ readfile
- bash: readfile: command not found
You're also unable to use code tags I guess.I am unable to run a C Program
Also, avoid attaching proprietary document formats. .txt is the format of choice.
If you understand what you're doing, you're not learning anything.
Closed for a bump
-Govtcheez
[email protected]