|
Yep that's a coding horror.
And by the way of course you can do that in C - try poking around in stdio.h and reading a book or two. Maybe use Google.
I am convinced that lobotomising users will make little to no difference.
|
|
|
|
|
Thats a very special kind of humour.
Greetings from Germany
|
|
|
|
|
Yes.
R.
T.
F.
M.
I still remember having to write your own code in FORTRAN rather than be a cut and paste merchant being pampered by colour coded Intellisense - ahh proper programming - those were the days
|
|
|
|
|
No, you have it wrong. He said he needed to read the file from the bottom:
M.
F.
T.
R.
Mostly, when you see programmers, they aren't doing anything. One of the attractive things about programmers is that you cannot tell whether or not they are working simply by looking at them. Very often they're sitting there seemingly drinking coffee and gossiping, or just staring into space. What the programmer is trying to do is get a handle on all the individual and unrelated ideas that are scampering around in his head. (Charles M Strauss)
|
|
|
|
|
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
#include "stdafx.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#define MEANINGFULL_SIZE 256
#define DELIM "\nexit 1\n"
#define FILE_DATA "hi\nhow are you\nexit 1\nthen\nyou\nexit 1\nand i can\nmake this\nexit 0\n"
int _tmain(int argc, _TCHAR* argv[])
{
char* filestr = (char*)malloc(MEANINGFULL_SIZE);
char* Found = (char*)malloc(MEANINGFULL_SIZE);
char* Current = {0};
memcpy(filestr,FILE_DATA,MEANINGFULL_SIZE-1); //pseudo readfile
Current = strstr(filestr,DELIM); //Find Stuff
memcpy(Found,Current+strlen(DELIM),strlen(Current));//copy what ever was found minus the delims
Current = strstr(Found,DELIM);//find the next delims
*Current = '\0'; //truncate the string
printf("%s \n",Found);//publish the result
while(1);
return 0;
}
Hope this helps u
modified on Tuesday, July 1, 2008 5:57 AM
|
|
|
|
|
|
evil
Yusuf
|
|
|
|
|
Standard header files should be included withh < and > .
eg. #include <stdio.h> .
Steve
|
|
|
|
|
Doesnt that just change the search scope for the file included? which will have little effect if it is increased scope maybe u wil lose 0.00000000001n.S in compile time. (realising that 85% of stats are made up on the spot)
if it does have some esoteric effect that i have been lucky enough to avoid thus far please educate me.
|
|
|
|
|
First off, it's good style. Secondly it effects the search paths used.
Steve
|
|
|
|
|
killabyte wrote: char* filestr = (char*)malloc(MEANINGFULL_SIZE);
Shouldn't soemthing be freed somewhere ?
|
|
|
|
|
yes in a perfect world
modified on Friday, July 11, 2008 9:16 PM
|
|
|
|
|
vineeshV wrote: Can anybody help me ?
Sure....how about picking the correct forum
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
At the risk of sounding stupid, why don't you do it two phases:
1. Read the file into a datatable, adding an additional column to represent a line number
2. Sort the table by line number (desc) and loop through.
Edward
Edward Steward
edwardsteward@optusnet.com.au
|
|
|
|
|
Just read the file into an array of lines, and loop backwards to the first occurrence of the delimiter (exit 1), keep track of the index you found and go from there.
Dybs
|
|
|
|
|
//initialize streamreader
StreamReader myStream = new StreamReader(@"c:\myfile.txt");
//read all the contents and store in string
string WholeFileString=myStream.ReadToEnd();
//convert to array
char []strArray = WholeFileString.ToCharArray();
//reverse the array
Array.Reverse(strArray);
//again convert to string
string newStr = new string(strArray);
//specify the split array (Note \r\n must be specified reverse becoz
string is reverse
char [] split = new char[2];
split[0] = '\n';
split[1] = '\r';
//receive the string array after spliting
string [] Lines = newStr.Split(split);
lines[0] = ; //last line of the file
lines[lines.Length-1] = ; //first line of the file
Regards,
Punithkumar
|
|
|
|
|
|
#define TRUE (C > C#)
|
|
|
|
|
A programmer told me he just learned try...catch, and found it's very powerful. Later, he found one of his methods always return null after he implemented try...catch. Here is his code:
private DataSet GetData()
{
DataSet ds = null;
try
{
ds = new DataSet();
}
catch
{
}
finally
{
ds = null;
}
return ds;
}
|
|
|
|
|
That said, I suggest you and your cow-orker might want to start by learning what the finally block does.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
You are as funny as the programmer. Did you think I am looking for help from you? Read my post again carefully please!
|
|
|
|
|
hmmmm .... this how he read the post ...
try
{
CheckIfPostIsInCorrectForum();
}
catch
{
WriteWrongPostMessage();
}
finaly
{
WriteWrongPostMessageExt();
}
*hehe*
|
|
|
|
|
I think this post is really on thr right forum
It gave me a laught
Sérgio Lima
Many people would sooner die than think; In fact, they do so.
- Bertrand Russell
|
|
|
|
|
Ummm, it is in the correct forum. The posted code is somewhat a horror.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|