C++ :: How To Modify A Header Of Any File
Jul 24, 2013All i want to do is modify a header of a file(.exe file). I just want to do if for fun and see what I can do with it.
View 3 RepliesAll i want to do is modify a header of a file(.exe file). I just want to do if for fun and see what I can do with it.
View 3 RepliesMy problem is that I have to modify only some specific details in a txt file (actually it is a wrl file but it can be considered as a txt file). There is a lot of text there but I just need to modify the point coordinates and leave the rest of the text as it is. Reading the "sample file" at some stage we will see some blocks that look like the below:
coord Coordinate {
point [
# bottom
-1.0 -1.0 1.0, #vertex 0
1.0 -1.0 1.0, #vertex 1
[Code] ....
where the numbers are (X,Y,Z) coordinates. What I have to do is to change those figures for (X,0,sqrt(X^2+Z^2)) points. Therefore the expected result (test file) will be as follows:
coord Coordinate {
point [
# bottom
-1.0 0.0 1.4142, #vertex 0
1.0 0.0 1.4142, #vertex 1
[Code] .....
So in my opinion it can be good to have two files: sample.txt and test.txt where the sample file will never be modified whereas the test.txt will be the same as sample.txt but including the modifications as explained above. The idea can be to read the sample.txt, store the info and then start copying each line in the test file until we get to the points coordinates (which needs to be modified) and continuying with this process until the next set of coordinates.
The problem is that I do not know how to change x,y,z coordinates from the sample.txt to (X,0,sqrt(X^2+Z^2)) and to copy them in the test.txt. Please see some code below and the sample.txt file attached.
//Read a Text File///////////////////////////////////////////////////////////////////////////////////////////////////
using System;
using System.IO;
namespace readwriteapp {
class Class1
[code]....
I derived a class from CRecentFileList in order to set the number of displayed chars for MRU.
The problem is that if I open the app with 256 set for this number (it is read from .ini file) the display is correct. But after I change it to 10 for e.g., File menu width remains unchanged altghough MRU are correctly displayed on 10 (or at least file name lenghts) chars.
how can I tell to the menu to shrink to actual width?
I have written my program and it works when I keep everything in the header files, and then have my main. I am now splitting them up into implementation files, but Eclipse keeps giving me errors. It gives me error at every opening brace of the constructor and functions. It says on all of them "Redefinition of (name of constructor or method), Previously declared here." What am I doing wrong, because it works in the header file?
#include "KeyValuePair.h"
template<typename Key,typename Value>
KeyValuePair<Key,Value>::KeyValuePair()
[Code] .....
I am working on an assignment in which i have to perform th following task
myClass itsObject1,itsObject2;
itsObject2=5000+itsObject1;
I have defined overloaded operator as follows in the header file but in the cpp file of the class it gives error.
friend vli &vli::operator + (int &a,vli &obj);
How to define it in cpp file of my class?
What is the right syntax for implementing the .cpp of a template class?
Consider this LinkedList.h file:
Code: #include<iostream>
#include"Iterator.h"
template <class T>
class LinkedList {
[Code] ....
How should the implementation for the LinkedList constructor, for example, should look like in the LinkedList.cpp file?
I tried this:
Code: #include "LinkedList.h"
template <class T>
LinkedList<T>::LinkedList<T>() {
// constructor
}
LinkedList<T>::~LinkedList<T>() {
// destructor
}
But the compiler wouldn't accept it.
lets say we have a valid class with full implementation, X. can this class be declared as forward in Y header file:
Code: class X;
class Y{
X* m_X;
}
but still be used as regular in the cpp file?
Code:
#include "Y.h"
#incldue "X.h"
T Y::function(){
m_X->doSomething();
}
visual studio prevents me from doing it , I wonder if the standard also says so.
I wanted to share the value of a variable from Sender Program to Receive after program and want to calculate difference between send and receive. After studying Header file concept I program following three.
Now I am struck. How to to compile? I link all these file. I used following method:
Code:
gcc Sender.c -o Sender Sender.h
gcc Receiver.c -o Receiver Student.h
Then I run Sender and after that Receiver.I per my knowledge, Receiver should give difference but it gives error :
Code:
Receiver.c: In function "main":
Receiver.c:10:42: error: "Send" undeclared (first use in this function)
printf(" Total Receive is %d
",Receive-Send);
Code:
Sender.c
#include <stdio.h>
int Send ;
void main(){
[Code] ....
I have been working a project in C++. I have TTTMain.cpp file that has all the function calls, TTTFuntions.cpp that has all the functions, I have TTT.h file that has all the prototypes and variables and additionally I have Winner.h that has enum class Winner declaration in it. Here is my block of codes:
Winner.h file:
#ifndef winner
#define winner
enum class Winner {
[Code]....
My question is when I compile this gives me error on
Winner gameSquares[] = { Empty, Empty,Empty, Empty, Empty, Empty, Empty, Empty, Empty };
with saying "invalid use of non-static data data member" and It says "Empty was not declared in this scope."
I know calling enum is very very trick.
I am beginner in c++ language. i'm use visual studio 2010 ultimate. the problem is i can't add c++ file(.cpp) and header file(.h).
Here the screenshot : [URL] ....
I made my header file. If cpp file with definitions is in project compiler knows it has to be linked, but if it's not compiler doesn't know. If I include standard library or boost I don't have to manually link cpps. How to do so including my header automatically links cpp? Maybe problem is with something else?I use VS 2013.
View 4 Replies View RelatedMy socket.cpp program got error. it showed "socket.h: no such file or directory". I had put my header file (socket.h) in the same place with my source file.
View 1 Replies View Related1. Write a program the calculates the volume of a sphere.
Use a define to set Pi to 3.14 and a macro for the formula for the sphere.
V = 4/3PiR3.
In main ask for the radius (R).
Pass it to a function where you calculate the volume and return it to main and print the volume in main.
Use float values. (Save this program as you'll need it later.)
Code:
#include<stdio.h>
void fun (float);
main()
[Code].....
Can we put using namespace std; in a header file? Someone told me not to do it, but I don't know why...
View 2 Replies View RelatedI need read a file with header and I wanna print the file in output. How can I do that? I tried but not work..
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
[Code]....
I have a class Myclass (for the sake of the example). I have a header file 'space.h', which is following:
#include "Myclass.h"
struct Files {Myclass* new_object, int number};
But turns out in the Myclass.h, I need the struct Files, like so:void function(vector<Files> arrangement);
So I would have to include "space.h" in the Myclass.h, but this way there's going to be a double definition of struct Files, since Myclass.h includes space.h and space.h includes Myclass.h.
Any good/solid example on how to create a header file?
View 2 Replies View RelatedI have written code for a timer. with everything and i want to include this so i dont need to write or copy the reqd code each time. how do i do this?
View 9 Replies View RelatedI wrote a simple date class and could not get it to work until I put all the code in main(). Then it worked like a charm. I have not been able to create a separate .cpp file and get it to work with my existing main().
I tried to follow [URL] which is a closed article, with no success. I tried every combination I could think of and was unable to compile without error. (Linux Mint 17,code::blocks 13.12, G++ 4.8.2). I did finally get it to work by putting *all* my code in the .h file and #including the .h file (and nothing else) in the .cpp file. This is not how it's supposed to work.
This is unbelievable! I just tried this on another computer, same OS same version of Code::Blocks and G++.
I am trying to compile two programs using the same header file and definitions. makefile part to make this work.
================================
My headerfile looks like this:
#ifdef ONE
void hello(int s);
#else
[Code]....
How can I include the flag -DONE in my makefile so that
it includes void hello(int s); for "one" and
int pin;
int verification(char* name);
for "two"
Here is my code
#include<msp430.h>
#include<stdio.h>
#include "contiki.h"
#include "isr_compat.h"
#include "string.h"
char dest[20]; //Global Variable
void uart0_send_data() {
[Code] ....
This code is used to transmit and receive the data. My only concern as of now is to create a header file for uart0_init() function.
I am trying to include a function from a header file named headerfunt.h . The code of my header file is
Code:
#ifndef HEADERFUNCT_H_INCLUDED
#define HEADERFUNCT_H_INCLUDED
#include <iostream>
[Code]....
But, while compiling it says abs was not declared... I have included the file.
I have written a small program for a class to convert decimal to binary and the program itself works, however, I am storing the binary bits in a stack that is in a header file (which I have used successfully before). It appears to push the bits to the stack just fine, however, when I use the printStack function I get a segmentation fault.
Here is the stack.h header file:
Code:
#include <stdlib.h>
#include <stdio.h>
struct stackNode {
int data;
struct stackNode *nextPtr;
[Code].....
And here is the main program that does the conversion:
Code:
#include <stdio.h>
#include "stack.h"
int binary (int x);
int main() {
int choice = 0;
printf("
[Code].....
One other thing of note, whenever I try to modify the printStack function, that function then seems to not work at all.
I'm trying to split up my game (about 1300 lines) into header files, but I'm coming up with a problem whenever I try and put a function in a header file, when that function was modifying some variables that were defined before int main in the .cpp. For example:
int variable1 (0);
int variable2 (0);
void increasevariables() {
variable 1 = variable1 + 1;
variable2 = variable2 + 1;
[code].....
If it only modified one variable then I could just pass that variable and the return it:(return variable1 + 1;)But I don't know how to make a function in a header file modify several pre-existing variables. In the actual program, the variables are dependant on each other and the modifying is a lot more complicated, so I'd rather not split it into several functions and run one at a time if there's another way.
I declared 3 private variables in header file.
I try to access one of the variable in its corresponding cpp file but I get an error message saying it's undefined. I did #include the header file. Why is this?
So say I create a header file which contains a list of structs, and I want to use these structs through out my source and some of my classes... how would I accomplish this?
When I try to do it via #include, I get re-definition errors, due to the nature of #pragma once. If I switch to #ifndef then I lack defenitions in files other than the source.
Is there a way to define things such as structs across multiple files, which doesn't lead to re-definition errors, and doesn't involve manually re-created all the structs for each file?