I think the first thing that happens is that you copy the NULL into s2[0] so when you try to print s2 nothing comes out.
A couple of other good habits:
1. use fgets or getline instead of gets http://www.crasseux.com/books/ctutorial/gets.html
2. It's a good habit to always initialize variables - I'm referring specifically to s1 and s2.
3. you don't need the first loop to find the end of s1, you can use strlen for th...
User Profile
Collapse
-
I've done this (in linux) using fuse-zip. It basically does the stuff Banfa said for you without you having to write that code.
http://code.google.com/p/fuse-zip/wiki/About...Leave a comment:
-
I can't compile your code because steine isn't defined in your example. I meant that steine is scarey because it's a 3 dimensional array and all that indexing might be goofed up (not because of it's name).
I still don't know what might be clobbering your stack. You can run valgrind or gdb (assuming you're running linux) or whatever memory/debugger you have.
f.good() checks to see if any of the streams failure bits are set...Leave a comment:
-
Not sure why it's giving you that error, but that steine array looks scarey.
You might want to check f.good() instead of (or in addition to) f.eof() because things can go wrong other than hitting the end of the file.
You can simplify your code greatly if you use std::string instead of char arrays. There's a std::getline that lets you read directly from a stream into a string.
http://cplusplus.com/reference/string/...Leave a comment:
-
You're comparing pointer values, not their contents. Try printing the hex value of s1 and s2 and you'll see they have different addresses.
To compare the value of the strings you have to use strcmp or something similar (or use C++ std::string)Leave a comment:
-
What is the reasoning behind that loop condition? (g2 <= g1) -- Are you sure you need to loop 1000 times? Maybe run your loop based on the size of the input string.
Also, you should change your #include <string.h> to #include <string>Leave a comment:
-
You can set permissions with udev rules
Some documentation that might help: http://www.reactivated.net/writing_u...html#ownershipLeave a comment:
-
Yes, it's not really millisecond resolution to divide by 1000.
Your operating system usually provides some timer library support. For instance, if you're working on linux you can use clock_gettime() and related functions to get better resolution timing (see 'man clock_gettime') .Leave a comment:
-
Leave a comment:
-
Well I didn't read your code (it's a lot), but the general idea is that the server will sit and listen for connections from clients. When a client connects the server will fork off another process (or start a thread) to handle that client. Then the server's manager process (or thread) will go back to listening for another client.Leave a comment:
-
The malloc's are allocating enough for one node, but the code acts like it's got an array of nodes.
"b" is one node, "c" is one node. There is no b[1] or c[1]. You should access b using pointer notation and not confuse yourself
b->i = 1;
b->next = NULL;Leave a comment:
-
Do you have a code sample? There may be a simple solution but we can't see what's going on yet.Leave a comment:
-
mac11 replied to In which zone of a flash memory could a write that will not get erase by formattingin C SharpWhat are you trying to accomplish exactly?
In general, if your program can write to some flash you (or somebody else/the OS) can erase it later.
Also "flash" is a really general concept. What specific "flash" are you dealing with? SD card, thumb drive, etc?Leave a comment:
-
I think you'd be better off having your list hold smart pointers (such as boost::shared_p tr). Then you don't have to explicitly delete anything and are much less likely to run into problems with raw pointers.
For an example see:
http://www.boost.org/doc/libs/1_46_1...tr_example.cpp...Leave a comment:
-
As a follow up to weaknessforcats , there's a C++ faq section for mixing C and C++
http://www.parashift.com/c++-faq-lit...c-and-cpp.html...Leave a comment:
-
This is called inter-process communication. There are several standard methods of synchronizing access to the file.
Being that you're using C# I suspect you're working in Windows so this article seems relevant. You can drill into it to get more details.
http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx...Leave a comment:
-
The immediate answer is that fwrite wants a pointer and you've given it a char. So give it a pointer:
Code:fwrite(&buffer, 1, 1, pBinaryFile);
You'll read the first byte "5", which is the ascii value of the character '5' and explicitly...Leave a comment:
-
I'd use grep
This will print all the "error" lines to stdout (assuming your file is called "filename")
Code:grep error filename
To replace the file in place you can also use sed
Code:sed -ie '/error/!d' filename
Leave a comment:
-
If you're typing input from the command prompt you type CTRL+Z for windows or CTRL+D for linux
If you're reading from a file it will just get an EOF when the end is reached automaticallyLeave a comment:
-
I'm sorry you're getting frustrated with this.
My comment wasn't meant to be inflammatory I just wanted to say that sometimes doing things may take more work than you'd prefer.Leave a comment:
No activity results to display
Show More
Leave a comment: