How to overwrite only part of a file in c++
I want to make modifications to the middle of a text file using c++, without altering the rest of the file. How can I do that? ...
I want to make modifications to the middle of a text file using c++, without altering the rest of the file. How can I do that? ...
Let's say I have a text file that is 100 lines long. I want to only change what is in the 50th line. One way to do it is open the file for input and open a new file for output. Use a for-loop to read in the first half of the file line by line and write to the second file line by line, then write what I want to change, and then write o...
In a text file I will have a line containing a series of numbers, with each number separated by a space. How would I read each of these numbers and store all of them in an array? ...
I'd be curious to understand if there's any substantial difference in specifying libraries (both shared and static) to gcc/g++ in the two following ways (CC can be g++ or gcc) CC -o output_executable /path/to/my/libstatic.a /path/to/my/libshared.so source1.cpp source2.cpp ... sourceN.cpp vs CC -o output_executable -L/path/to/my/libs ...
I have Eclipse set up fairly nicely to run the G++ compiler through Cygwin. Even the character encoding is set up correctly! There still seems to be something wrong with my configuration: I can't debug. The pause button in the debug view is simply disabled, and no threads appear in my application tree. It seems that gdb is simply not co...
I have a problem. I wrote example code and I want to build it without the error: main.cpp(.text+0x5): undefined reference to `test()' Library test1.c #include <stdlib.h> void test() { puts("Działa"); } test1.h #ifndef TEST1_H #define TEST1_H extern void test(); #endif makefile all: gcc -c ./src/test1.c -o ./lib/test1.o ...
g++ compiler gives this error: expected `;' before 'it' template <typename T> class myList : public std::list<T> { public: void foo () { std::list<T>::iterator it; // compiler error as above mentioned, why ??? } }; Thanks. ...
Note, my question is not: how do I tell my compiler to compile with profiling on. I want to profile my compiles process. For each file, I'd like to know how much time is spent on each line of the program. I'm working on a project, some files have huge compile times, I'm trying to figure out why. Is there anyway to do this with g++ or ...
Hi I want to see how g++ lays out memory for classes and virtual tables. Is there a way to dump this information, using g++'s options? Thanks ...
I have some C++ code #include <cstdio> #include <boost/bind.hpp> #include <boost/function.hpp> class A { public: void do_it() { std::printf("aaa"); } }; void call_it(const boost::function<void()> &f) { f(); } void func() { A *a = new A; call_it(boost::bind(&A::do_it, a)); } which gcc 4 compiles into the following as...
I have a simple logger that is implemented as a singleton. It works like i want when I compile and run it with g++ in linux but when I compile in Visual Studio 9.0 with vc++ I get the following errors. Is there a way to fix this? I don't mind changing the logger class around, but I would like to avoid changing how it is called. 1>Linkin...
Working on Mac OS X 10.6.2, Intel, with i686-apple-darwin10-g++-4.2.1, and compiling with the -arch x86_64 flag, I just noticed that while... std::numeric_limits<long double>::max_exponent10 = 4932 ...as is expected, when a long double is actually set to a value with exponent greater than 308, it becomes inf--ie in reality it only has...
Hi, I'm trying to learn a little bit C++ and Boost.Asio. I'm trying to compile the following code example: #include <iostream> #include <boost/array.hpp> #include <boost/asio.hpp> using boost::asio::ip::tcp; int main(int argc, char* argv[]) { try { if (argc != 2) { std::cerr << "Usage: client <host>" << std::endl; ...
I'm having an issue getting some code to work. Is there a way to enable headers to be included like so #include <boost/asio.hpp> Instead of #include "boost/asio.hpp" ...
Is there some ultra fast "syntax check my code, but don't compile mode" for g++/clang? Where the only goal is to just check if the code I have is valid C++ code? ...
cout << "Input street number: "; cin >> streetnum; cout << "Input street name: "; cin >> streetname; cout << "Input resource name: "; cin >> rName; cout << "Input architectural style: "; cin >> aStyle; cout << "Input year built: "; cin >> year; The problem ...
Hi Guys, This will probably be a bot of a waffly question but ill try my best. I have a simple c++ program that i need to build testing for. I have 2 Classes i use besides the one i actually am using, these are called WebServer and BusinessLogicLayer. To test my own code i have made my own versions of these classes that feed dummy da...
Hi Guys, I have a, int main (int argc, char *argv[]) and one of the arguements im passing in is a char. It gives the error message in the title when i go to compile How would i go about fixing this? Regards Paul ...
I have this output when trying to debug Program received signal SIGSEGV, Segmentation fault 0x43989029 in std::string::compare (this=0x88fd430, __str=@0xbfff9060) at /home/devsw/tmp/objdir/i686-pc-linux-gnu/libstdc++-v3/include/bits/char_traits.h:253 253 { return memcmp(__s1, __s2, __n); } Current language: auto; currently ...
Hi Guys, Im trying to use some of the functions that are in the /lib/libproc-3.2.6.so library in my Ubuntu Distribution. I have downloaded and installed the header files and they are defined in my source files. Currently this is all im trying to do, just for starters... proc_t **read_proc = readproctab(0); But i get the following...