C++ :: Printf Is A Part Of Code Segment But Found In Data Segment?
Sep 28, 2013printf is a part of code segment but found in data segment.....why is it so ?
View 7 Repliesprintf is a part of code segment but found in data segment.....why is it so ?
View 7 RepliesI would like to cipher data segmet of my executable say with a simple Caesar Cipher algorithm, i.e. any text should not be readable when executable opened with a hex editor.
It should be something that converts my plain text into a ciphered form at compile time(CPP?), and when executable is being run, should be able to convert ciphered data into human readable text.
I thought meta-programming could be the approach for this. Also, implementing complex algorithms with C pre-processor (CPP) sounds vulnerable (well, depends on one's coding skills let me say)
I am trying to write a client/server application that takes input to an array of structures from the user,stores the data in a shared memory segment and then writes the same to a file when I close the application. How do I get started? And how do I ensure that the server stores the data correctly? Also, the server needs to be a concurrent server that accepts connections from multiple clients.
View 1 Replies View RelatedThe below code is giving me segment fault during delete [] (*iter) sometimes. Is it not the proper way to delete the vector with char *
Code:
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<char*> nameList;
for (int i=0;i<1000;++i)
[Code] ....
I need updating binary search three. I am working on implementation of Bentley-Ottoman algorithm for finding intersections of line segments in the plane. Code I designed works properly for all, but certain types of triangles. What is happening is that one intersection inside the triangle is never detected due to a fact that segments which intersect in that point never become neighbors in binary search tree.
class segment{
double x1,y1,x2,y2;
int name;
[Code]....
for example i have
int count = t1;
while(count>counter){
Sleep(delay);
Int32::TryParse(textBox2->Text,add);
result = result + add;
counter = counter + 1;
Problem is that sleep stops all program for specified time, Is there an alternative to sleep that would only stop part of code or can i use sleep different way to specify what it pauses?
Code:
#include <cstdlib>
#include <iostream>
#include <string>
#include <stdio.h>
#include <windows.h>
#include <conio.h>
#include <exception>
#include <process.h>
using namespace std;
int main(int argc, char *argv[])
[code]....
I'm trying to create a program that will show what the 12th digit of a UPC code would be. However, once the user enters the first 11 digits the program doesn't execute the last call of printf. The program compiles with no issues.
Code:
#include<stdio.h>
int main() {
int o1, e2, o3, e4, o5, e6, o7, e8, o9, e10, o11, oddsum, evensum, twelve;
printf
[Code] .....
main()
{
printf("%lf",5/2);
}
this code is giving runtime error ....why ?
I'm trying to get this programme to work but I can't get it to output the string data at the end of the line.I have copied and pasted the line in question below but it may be a prob with the prog further down.
It reads character input ok but doesn't put one string into another or recognize when a string is quoted in a printf.
Code:
printf("%s what is your second name?
", surname, name2, name);
#include <stdio.h>
int main ()
{
char name[20];
[Code] ....
I've got some code in C++ that does some basic analysis on price data and I run it from the cmd prompt. One of the functions I had built to read in the data is as follows:
void ReadPricesFromFile(constchar*filename,std::vector<PriceInfo>&prices)
{std::ifstreaminput(filename);
input>>prices;}
How would one merge this type of code into a Qt GUI? Ideally, I'd like to use something like QFileDialog to open up a folder with my data files, select a file, and then read the file that the user selects. Would the main.cpp look something like this?
int main (int argc, char *argv []) {
QApplication prog (argc, argv);
QPushButton *load_button = new QPushbutton ("Load File");
QObject:: connect (load_button, SIGNAL (clicked()), &prog, SLOT ( (ReadPricesfromFile function?);
load_button-> show ();
return prog.exec ();}
I am trying to read data from more than one file at once. The files are different types e.g. one is a text file one is an xml file like so, StudentInformation.txt, CollegeInformation.xml. The files are all stored in one place, in this case on the D drive of a local computer. I am trying to locate any files in the D drive with a file extension of .txt or of .xml (there may be more than two of these files in the future, so I'm trying to allow for that). Then I want to open all of these files, extract the information and output all the information in one display window. I want all the information from these two or more files to be displayed together in the display window.
Here is the code so far. It is throwing up errors.
//Load from txt files
private void btnLoad_Click(object sender, RoutedEventArgs e)
{
IEnumerable<string> fileContents = Directory.EnumerateFiles("D:\", "*.*", SearchOption.TopDirectoryOnly)
.Select(x => new FileInfo(x))
.Where(x => x.Extension == ".xml" || x.Extension == ".txt")
.Select(file => ParseFile(file));}
[Code] ....
The error it throws up is:
Error 1 'BookList.Mainwindow.ParseFile(System.IO.FileInfo)': not all code paths return a value
I have a piece of code in C with header files included. I run it on Mac OS X Maverick with XCode 4.6.2 installed. GCC is also installed. Note that Command Line Tools in XCode are already installed.
When I compile it, the error I receive says something like this:
add.c:1:19: error: stdio.h: No such file or directory add.c:2:20: error: stdlib.h: No such file or directory add.c:3:20: error: unistd.h: No such file or directory
However when I run it on Ubuntu, it compiles without a problem.What to do?
Say I have a structure defined as such:
struct data{
char c;
int x;
};
And I want to create a function to print either c or x. However, I don't want to just use a switch or something to figure this out, I want to reference which part I'm outputting.
Now here's the twist
vector<data> dataList;
I need to access element x or c in the vector, but all I pass is the vector and which element, so that I might have something like:
void (vector<data> x, DataType i){
cout << x[0].i;
}
So now, if I pass either x or c (someway), I can output one of them.
I am working on a couple C++ projectsfor my class. On one of my projects I get this error "identifier not found" for maximumValue. here is the code that I have done. I have got almost all the code from my text book..
// Three numbers.cpp : Defines the entry point for the console application.//
#include "stdafx.h"
#include <iostream>
using namespace std;
int main() {
// demonstrate maximum int value
int int1, int2, int3;
[Code] .....
I have counted my braces and it look to be correct but I am seeing double.. I am getting the "end of file found before the left brace.. do I have one in an incorrect place?
#include <iostream>
#include <string>
#include <fstream>
#include<cmath>
using namespace std;
int totalCaloriesBurned (double);
[Code] .....
Is there any way I can clear only a selected part of the screen? (I'm aware of system("cls"))
For example, when you enter a date, and is wrong, could it just errase that input and only say "Wrong try again" without errasing everything else you where doing?
In this case, a function that only errases what is in the while
while(not wrong)
{
cout<<"DIA: ";
cin>>obj.dia;
cout<<"MES: ";
cin>>obj.mes;
cout<<"ANIO: ";
cin>>obj.anio;
}
PS: Also, is there any whay in which you can ask the user to enter the date DD/MM/YYY?
I am trying to link OpenCV to my qt project, but for some reason it doesn't seem to able to find my files. my .pro file looks like this
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = opens
TEMPLATE = app
INCLUDEPATH += /usr/local/include
HEADERS += mainwindow.h
LIBS += -lm -lopencv_core -lopencv_highgui -lopencv_video -lopencv_imgproc
SOURCES += main.cpp
mainwindow.cpp
FORMS += mainwindow.ui
I get the error message saying library not found for -lopencv_core and it is the same for the other ones.
I've been following this guide : [URL]
What is going on?
Is it valid for an object to return an object of they same type? GetBlock method
class memBlock {
private:
char *mem;
unsigned long length;
public:
memBlock(char *data,unsigned long startPoint, unsigned long endPoint) {
[Code] .....
I am having a little bit of trouble with what should be a simple part in my code. For some reason it keeps looping the name part of the program and I seem to be passing over the problem in the code.
Here is the code:
#include <iostream>
#include <string>
using namespace std;
[Code]....
I have the following string: "type computer {dell}"
And I want to remove the {dell}
So that the output on the screen type computer
Or delete any clause between the two brackets {}
How do i do that ?
tell me which .dll or library I'm supposed to use to link this program:
#include <iostream>
using namespace std;
void antpost (int num, int& anterior, int& posterior) {
anterior = num-1;
posterior = num+1;
[Code] ....
I think my linker needs an additional #include to be able to deal with int& anterior and int& posterior. I'm not sure as I'm new to C++. My version of Dev-C++ is Orwell V5.8.3.
Code:
// string::erase
#include <iostream>
#include <string>
int main () {
std::string str ("This is an example sentence.");
std::cout << str << '
';
str.erase (10,8);
std::cout << str << '
';
Code:
Output:
I don't understand this program. What do these 2 numbers represent? The index of an element in a character array? The 10th character of the array is 'n' and 8th is a "space".
I'm having a problem converting part of a string to an integer.I used strtok to seperate my string and I have also a function for atoi but how to apply it to my strtok function.What i need is to change the char *years to an int.Have a look of what I got:
Code:
int main() {
char sentence[]="trade_#_2009_#_invest_#_DEALING";
char *word=strtok(sentence, "_#_");
char *year=strtok(NULL, "_#_");; // assigning NULL for previousely where it left off
char *definition=strtok(NULL,"_#_");
char *synonyms=strtok(NULL,"_#_");
[code]...
I have a character array that includes configuration bits that are 0x00, thus when I try and do a strcat it adds the appended string into one of those spots instead of the end of the array.
View 2 Replies View RelatedI'm having some trouble printing the duplicates found in an array. Specifically, when the value is at more than 2 positions. So if the value 3 is at position 1, 10, and 11 it'll print three messages instead of two:
value 3 at position 1 is also at position 10
value 3 at position 1 is also at position 11
value 3 at position 10 is also at position 11
instead of
value 3 at position 1 is also at position 10
value 3 at position 1 is also at position 11
This is real simple problem, but I can't seem to figure it out. I've been trying to implement another array to 'remember' the encountered position, but I haven't had any luck.
Code:
for(i = 0; i < num_count; i++){for (j = i + 1; j < num_count; j++) {if (num[i] == num[j]){printf("
value %d at position %d is also at position %d", num[i], i, j);}}}