ALL your template functions in the cpp file need to be in the .h file.
When you instance a template with a type, the compiler needs all the template code to generate the appropriate type-specific instances of those functions.
ALL your template functions in the cpp file need to be in the .h file.
When you instance a template with a type, the compiler needs all the template code to generate the appropriate type-specific instances of those functions.
> while (check = 0)
So ==
Did you use -Wall ?
It will catch a lot of problems which are legal, but stupid.
> for(i=0; i < row; i++);
Yeah, guess what that last ; does
IIRC, something like -Wall as a compiler option would be a good idea.
> $(CC) $(CFLAGS) -o 3Dfilter filter.o $(IO)file_io.o $(CFLAGSPOST)
This does NOT have -c
All the other ones need -c
Post a log.
So does it work?
Post your latest if not.
Depends on the scale of the problem.
If you can "see" the whole problem at once, then just doing the code is probably fine.
But if it's going to take you more than a day (or you plan on maintaining it in any way), then some kind of design is essential.
You wouldn't approach building a flat pack garden shed in the same way you would a house or a skyscraper.
Flow charts are just one of many ways of looking at the design problem.
3DFilter: filter.o $(IO)file_io.o
$(CC) $(CFLAGS) -o 3Dfilter filter.o $(IO)file_io.o $(CFLAGSPOST)
filter.o: filter.c $(IO)file_io.h includes.h
$(CC) -c $(CFLAGS) filter.c
file_io.o: $(IO)file_io.c $(IO)file_io.h includes.h
$(CC) -c $(CFLAGS) $(IO)file_io.c
Everything except the executable needs -c (compile only)
The executable needs all the libraries.
http://clusty.com/search?input-form=clusty-simple&v%3Asources=webplus&query=0xC00000FD+site%3Amicrosoft.com
I'd say your arrays are a lot larger than you thought.
Post your latest code, describing what you did doesn't work.
Whenever you create a new node, you need to make sure new_node->next is NULL.
Well we could guess, or you could post code.
So are you in control of either the producer or consumer, source code wise?
Is the producer a perl script?
You should stop using the register keyword all over the place as well.
Modern optimising compilers are far better at figuring out best use of registers, and will just ignore it. So save yourself some typing.
> printf("===========================");
> fnGotoxy(25,8);
I know these seem important, but they're not. Just rip them all out until you've got the core program working, after which it's dead easy to put them all back again.
Such eye candy only makes the code a lot longer than it needs to be, and distracts you from taking care of the real problems in the code.
> fnOpenFile(DEP_FILE);
How about paying attention to the return result of this function?
Like having tried to open a file for writing, which you've already got open for reading.
Here's how I know
> Debug Assertion Failed!
> Program: F:\EIS\dept1\Debug\dept1.exe
> File:fgets.c
You failed to open a file, so your FILE * pointer is NULL.
This is what this debug assertion is telling you, that you passed NULL as the stream to some file reading function.
The shell will allow you to create multi-line awk programs, which in this case would allow you to only read the file once, AND be sure that the $4 you see printed is the $4 being summed.
awk 'BEGIN {
print "Name, Position, Department, Salary"
print "========================================"
FS=","
RS="\n"
}
{printf "%s, %s, %s, %s\n", $1, $2, $3, $4}
{total += $4}
END {
print total
}' $dataFile
Strange, that would have worked - post your latest code.
> printf("Error: can't open file.\n");
Use
perror("can't open file.");
It'll tell you WHY it can't open the file.
Like all good habits, you'll do the right thing automatically when it really matters.
But if you write crap code just because you can get away with it, then you're in for a lot of hard lessons later on.
temp is still a string, how obvious do you need it to be?
Well that depends on your OS.
Your average desktop with an OS which runs each process in a separate address space will reclaim the space when the program exits.
But if you're programming on say a mobile phone, where there is no virtual memory, and not a lot of operating system, then a thread which dies will just leave a big mess in memory with no clear way of fixing it.
Well you did input temp as a string (this time), and not as a float (like last time).
Focus on what's being said, and stop making a bunch of random changes each time.
I would have hoped after 40 posts that you would have figured this out.
Or at least read it.
http://www.daniweb.com/forums/announcement113-3.html
<yoda>
Mmm, too late 3 years are you - still relevant you think not, mmm?
</yoda>
> float celcius = (temp-32)/ 1.8 << endl;
So what's the endl doing at the end of this calculation?
> for(int h = 0; h <= b;)
How long is the loop going to run before h > b ?
Check ALL your fopen calls for success.
Check your scanf functions for success.
One while loop to input a guess, then 3 tests.
You'd have to post your latest code, and highlight the line containing the error message.
Heh - 9/5, how about that then ^^^^^
Maybe post your formula for converting F to C?
You didn't do 5/9 by any chance, which would be 0
As opposed to say 5.0/9.0 which is nearer to what you want.
Not entirely. gcc (which I guess you're using) has some built-in functions (as evidenced by the second message). First, turn these off to get a better idea of what's going on. gcc -fno-builtin malloc.c
This done, the compiler should be then forced to follow the normal C sematics for undeclared functions, which would be
int malloc();
Since you're assigning to a pointer at that stage, you should end up with the "int to pointer" message.
There is no standard for error messages (except where the standard says an error message is required), so wording and numbers of error messages vary between compilers.
> My thought would be that I assign the chars to the memory and therefore the initial value is irrelevant?
Two things about strncat
1. It attempts to find a \0, then appends characters. If memory is filled with garbage (which it is), then you're appending the data in an unknown place.
2. strncat doesn't always append a \0, so you lose again.
You already have an index, so use it.
wrd[wrdlen] = ch;
wrd[wrdlen+1] = '\0';
simple, works.
> wrd = (char*)realloc(wrd, (wrd_len+1)*sizeof(char))
1. was it really worth dropping a single letter?
2. wrd_len never gets incremented.
3. you're assuming the memory returned by realloc is zero filled - it isn't.
4. your use of realloc is unsafe, but more on that later no doubt.
Oh, thanks for the update, be sure to add more information later.
Just put
ls
in there for now.
It's not magic, it's just a list of commands you want done every time you either login or create a new shell.
Copy the example dot.bash_profile to your home directory as .bash_profile
Then start uncommenting the bits you would like, and adding any new things you would like.
Something like this (untested)
while ( 1 ) {
while ( fgets(line,size,fp)!=NULL) {
// process lines
}
clearerr( fp ); // reset end of file flag
sleep( 1 ); // wait for more lines to arrive
}
It really depends on what you want to achieve.
// disallow param = something and *param = something
void doSome(const int * const param)
// param can be changed, but what it points to cannot
void doSome(const int * param)
// you can't change param, but *param = something is fine
void doSome( int * const param)
// open season on any assignment
void doSome(int * param)
It's up to you to decide how much const correctness you want to have in your code.
But beware that a partially const correct body of code can be a real nightmare to work with, particularly where const-correct code makes calls to code which isn't.
If you call malloc, then you need to call free.
The compiler looks after allocation and deallocation of local variables.
It seems to me that reads up to the first newline, then exits.
Is that what you want?
while ( fp1 >> ch ) {
}
should read the whole file.
If you've got something to do at a newline, then
while ( fp1 >> ch ) {
if ( ch == '\n' ) {
// woo hoo, newline goodness goes here
}
}
I can see what they are.
But I'd rather see words like IN_COMMENT or POSSIBLE_COMMENT as the names of states, rather than what you've got.
With decent names, it might be plainly obvious that you can't (for example) get from IN_COMMENT to END_OF_LINE in one character.
A B C do not do that.
Perhaps something more meaningful than A B C etc
No, go away and think for yourself.
Or better yet, search this forum for all the other lamers who roll past with "please suggest a project" threads.
You've been on a course for several years, has NOTHING inspired you to think "hey, that would be good....". If not, you've wasted your time, and now you're wasting ours.
Yes, you're using tr wrongly.
tr just translates (or deletes) characters. Not lines, or things matching lines.
You could try
grep -v $remEmp $dataFile > temp
mv temp $dataFile
which finds everything EXCEPT (that's -v, invert) what matches the thing you want to remove.
> sed -i 's/oldInfo/newInfo/g' "$dataFile"
You need to watch your shell's quoting rules.
Things in single quotes are preserved as is
Things in double quotes allow $substitutions.
Perhaps then
sed -i "s/$oldInfo/$newInfo/g" "$dataFile"
This is a partial list of GNU text utilities
http://www.rtr.com/win95pak/textutils.htm
Then there is
grep / egrep / fgrep - file searching
sed - simple file manipulation
awk - more complex file manipulation
perl - the ultimate swiss army knife :)
CreateProcess ( "C:\\abc.exe", " \"C:\\Documents and Settings\\xyz.exe\" 2", NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS,
NULL, NULL, &si, &pi );
Some well-placed \" perhaps?
http://www.ss64.com/bash/gawk.html
Eg.
awk -v find="Fred" 'BEGIN{FS=","; RS="\n"}
$1 == find {printf "%s, %s, %s, %s\n", $1, $2, $3, $4}' data.txt
Just replace the green code with whatever test you like.