C :: Reading RAM Memory Directly
Mar 27, 2014
Is there any way to read RAM memory directly. For say i want to access memory location 0x0100 to 0x120. How to do that. how to declare the variable, is it unsigned int. what is the type of read values it hex or ascii. how t cast it.
View 2 Replies
ADVERTISEMENT
Jan 20, 2014
I have a C program. Within it, I would like to embed either a file or a pre-assigned variable. I would prefer a method that is platform independent.
I am using the data type "RSA" from <openssl/rsa.h>. I have a key file in PEM format, but I would like to embed an RSA object in the program instead. I tried creating a char array and then casting the pointer, but that caused some sort of illegal casting issue. I tried using memcpy but I haven't been able to get it working that way. What is the best way of going about this? Is it possible to read a file directly from a memory buffer?
View 1 Replies
View Related
Aug 3, 2013
I am having a problem with a small exercise program. The program works the first time through the loop but not the second. It faults on this line:
cin >> *(pint + i1);, with this error: pint <Unable to read memory>.
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
int MAX(5);
int count(4);
int value(MAX);
[Code] ....
View 5 Replies
View Related
Jul 26, 2014
I have a csv file (comma delimited text file really) and I have data ,about 6400 lines, and I need to read and display data from 1 line. At the bottom is sample data from my csv file.
I want to read onto the screen the 3rd item .. ie Test User 1 and the date and time at the end (the last 2 items).
I will enter in a number .. from which I will want to retrieve the appropriate record .. in this case I would enter in 514, 563 or 874 and get back the info for that record.
This is a DOS 16 bit application .. and I know that some of the data is in memory already but I am not sure how to tell .. or how to retrieve it.
I do have the ability to save the data to the file at any time .. so I can use that to ensure that the data is current in the text file before I retrieve the data from this 1 row.
I think that it may just be easier to get from the text file ? but I am not sure.
0000,7,0,"Test User 1",53c145cb,db,5,514,514,2014/07/12,10:27:23
0001,7,0,"Test User 2",53d7f,1903,10,563,563,2014/07/24,11:04:31
0002,7,0,"Test User 3",529c,5ffb03,0,874,874,2013/12/02,09:07:58
I am a database guy .. and I am just a bit lost when it comes to C programming as such.
View 9 Replies
View Related
Mar 9, 2012
I'm using a uC to read the device ID from a One Wire device. I'm trying to have the ID read every second and output to over a USART serial stream for debugging, however I'm having a number of problems getting this to work correctly and I think it has to do with my misunderstanding of memory allocation in this case.
The problem is that when I upload the binary to the uC, it gets the device ID correctly the first time, and from thereafter the program is unstable and starts returning garbage (1st screenshot).
Ideally everything inside of the while loop would be inside of its own function, however I have had nothing but trouble doing that. In fact, when I put that all into it's own function that returns void and takes BUSES as an input, the correct data comes out the first and therefore it somehow exits the "while" loop and never gets back in (2nd screenshot). Another thing I noticed is that when I put the variable declaration outside of the while loop in the code below, I get the same behavior.
I haven't include the code for OWI_DetectPresence and OWI_SendByte ... I've hooked up an oscilloscope and have visually confirmed they are working correctly. Once the OWI_ROM_READ byte is sent over the bus the slave responds with it's device ID. I feel like my issue here is memory allocation and not hardware.
how to fix the issue with the output to USART and how to make this into a function that returns the string of the hex ID?
Code:
int main(void) {
unsigned char OWI_on_bus = FALSE;
// initialize UART for debugging
Init_USART();
[Code].....
View 2 Replies
View Related
Mar 25, 2014
I'm successfully publishing an app to my website by publishing locally and then uploading the files but one of the options offered is to publish straight to the web site but I can't find anywhere to enter a user name and password for my web site. I could also do it with ftp but since the option is offered to publish directly to the web site I'd like to try that method. I'm using the Click Once method.
View 5 Replies
View Related
Nov 25, 2013
I wish to convert a character directly to a string for a top-secret project I'm working on. It needs to be portable across various machines with different sized Indians.
Code:
#include <stdio.h>
int main(void)
{
const int i = 0x0041;
const char *str_p = (char *) &i;
}
[code]....
I want this to output an 'A', but I'm not sure this code will work on my friend's mom's S/360.
View 2 Replies
View Related
Mar 5, 2014
I don't know how to put this really, but I finished a program in Qt, and i want to know how to make a .exe file for it, so i dont have to open Qt and build the program every time i use it.
View 2 Replies
View Related
Jul 1, 2013
I've got two classes, which are both derived from the same two base classes. Here's a representation of the actual code:
Code: #include <vector>
class BaseClassA {
};
class BaseClassB {
};
class TestClassX
: public BaseClassA,
public BaseClassB
[code].....
Basically, I'd like to know if it is possible to cast directly from a BaseClassA pointer to a BaseClassB pointer, without casting to the child class first.
View 10 Replies
View Related
Nov 24, 2014
I'm learning OpenGL using the C API and some of the functions' argument types have proven a bit challenging to me.
One example is the function Code: glShaderSource(GLuint shader, GLsizei count, GLchar const** string, GLint const* length); It resides in foo() which receives a vector "data" from elsewhere Code: void foo(std::vector<std::pair<GLenum, GLchar const*>> const& data); To pass the pair's second element to glShaderSource's third argument, I do the following:
Code:
GLchar const* const source[] = {data[0].second};
glShaderSource(..., ..., source, ...);
Now I have two questions regarding this:
1. Can I initialize a char const** via initialization list, the way I do a char const*?
Code:
// this works
std::vector<std::pair<GLenum, GLchar const*>> const shader_sources = {
{GL_VERTEX_SHADER, "sourcecode"},
{GL_FRAGMENT_SHADER, "sourcecode"}
};
// but is this possible?
std::vector<std::pair<GLenum, GLchar const**>> = { ??? };
2. Is there an alternative to creating a temporary GLchar**, even though that's specifically what the function wants?
View 2 Replies
View Related
Sep 14, 2014
Is it possible to create a dynamic char array on the fly directly from stdin? I do not want to create a fixed length array before hand and then copy contents of it into a malloc created array.
Code: //[1]
char line[MAX1];
gets(line);
[Code]....
I could do either [1](buffer overflow problem) or [2] and then goto [3]. But both will have a problem if the input is more than the size MAX1(use defined).
Is it possible to do something of the effect of readLine() method of BufferedReader class in Java or the Console.readLine in .NET? Is it possible to peek into stdin and see the size of the input and then creat an array of the same exact size?
View 8 Replies
View Related
Jan 26, 2015
I'm trying to use a class member to initialize the dimension of a matrix. I have two issues. Here is the code (.h) simplified :
#include <vector>
#include <array>
#include <typeinfo>
template<typename T, std::size_t N>
struct md_vector {
[Code] ...
error: invalid use of non-static data member ‘OptimalSamplingStrategy::_nbMorph’|
I can't use a class member directly in the header file (here _nbMorph).
It was an issue I got before and that I didn't solve as I succeed in finding other ways. I don't think it's possible here.
View 1 Replies
View Related
Apr 19, 2014
Exporting the data from the sql database to excel directly.this code is not working and i am not getting file in particular location. My connection string is :
Data Source=aswin-pcsqlexpress;Initial Catalog=pro;Integrated Security=True
using Excel=Microsoft.Office.Interop.Excel;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication5 {
public partial class Form1 : Form {
SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["SqlCon"].ToString());
[code]....
View 1 Replies
View Related
Mar 19, 2013
Below code produces run-time segmentation fault (core dumped) when execution reached line 53: delete [] array
Code 1:
#include <cstdlib>
#include <iostream>
using namespace std;
#define QUANTITY 5
class Parent {
protected:
int ID;
[Code] ....
Output of code 1:
Constructor of A: Instance created with ID=1804289383
Constructor of A: Instance created with ID=846930886
Constructor of A: Instance created with ID=1681692777
Constructor of A: Instance created with ID=1714636915
Constructor of A: Instance created with ID=1957747793
A::showID() -- ID is 1804289383
A::showID() -- ID is 846930886
A::showID() -- ID is 1681692777
A::showID() -- ID is 1714636915
A::showID() -- ID is 1957747793
Try to delete [] array..
Segmentation fault (core dumped)
Question: Why does segmentation fault happen in code 1 above?
View 9 Replies
View Related
Jan 10, 2014
I have a service that has some settings. As the service is running as a system user, the settings file is located in
C:Windowssystem32configsystemprofileAppDataLocal<PRODUCTNAME><ExecutableName+GUID><VERSION>user.config
Now i want to be able to change some settings at runtime using a normal Winforms App. Is there a good and easy way to change the user.config of a different application directly? I tried with ConfigurationManager but that does not seem to work.
View 8 Replies
View Related
Feb 5, 2013
I am wondering if I have the following parameter to pass in to a function
Code : void Load(std::wstring filename);
This statement is wrong.
Code : Load("DataMesh.x");
I don't want to pre-declare a variable. How do I directly pass a wstring (literal) to this function.
View 2 Replies
View Related
Apr 14, 2015
I am trying to query dates between two textbox values converted to datetime in C#. The dates are returning in the correct datetime and no conversion problem exists there.
However when I run the below LINQ to SQL query in C# it returns no enumerable results. But if I take the below code:
DbCommand dc = dbHistoryContext.GetCommand(qryRes);
Console.WriteLine(dc.CommandText);
and get the results as a string of text and cut and paste that into the SQL Server Management studio and execute it - then it works. What do I need to do to search between two dates so that it properly works. The field is of format Date in SQL Server if that matters and the fields being used to pass the information to it are DateTime. The compiler doesn't show any errors but it just doesn't return results.
var qryRes = (from res in dbHistoryContext.tblR
where res.updateddate >= dtDateFrom.Date && res.updateddate <= dtDateTo.Date
select res);
View 8 Replies
View Related
May 17, 2012
I have a strange problem in using C code. I want to move focus from one item to another in a keypress event (like keydown)in loop. But it move directly to the last item
Details: In the code segment, I am generating keypress event explicitly from code and want to move focus for number of items inside loop. Loop is working properly, but output is also generated after completion of loop and focus is directly coming on last item in list not showing intermediate movements. Voice output using espeak is generated correctly in each iteration.
Tryouts: I have tried to call a dilog box which take yes/no event by Btn press,that works fine. That means event generation in code is giving problem, it needs h/w intervention for keypress (As I understood)..
View 10 Replies
View Related
Mar 19, 2013
I had a quick question regarding a program I am trying to complete. I have the basics worked out, and everything seems to be done, but I am running into two issues.
1= The program keeps telling me "Run-Time Check Failure #3 - The variable 'order' is being used without being initialized."
and
2= When I reach my output screen I receive "Unhandled exception at 0x7751c41f in CISC 192 Project 3.exe: Microsoft C++ exception: std:Out_of_range at memory location 0x002eefb8.."
While the first one isn't necessarily a deal breaker the second one definitely is.
Code:
// Bookstore Project 3.cpp : Defines the entry point for the console application.
// Declarations
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <istream>
[Code] ....
View 2 Replies
View Related
May 11, 2013
I'm trying out the gmp library by building a simple pi calculation program (original, I know!). On a million digits of Pi I've debugged the program and seem to have about a megabyte too much of memory at the end of the program (I start with around 250k before any allocation begins and end at around 1200).
int main(int argc, char *argv[]) {
//set a//
int digitsofpi =1000000;
mpf_set_default_prec(log2(10) *digitsofpi );
mpf_t a;
mpf_init (a);
mpf_set_ui (a,1);
[code].....
View 2 Replies
View Related
Mar 8, 2013
I am looking for a way to run a process form memory, without having any executable. The application will be kept inside a resource and will be extracted during run time. It should be then started as a new process. I couldn't find a solution that works also on x64
View 5 Replies
View Related
Nov 6, 2014
We have a proprietary third-party library that we make calls into via an API. Through a series of API calls, this library manipulates specific sets of data. Prior to making these calls, there are some API calls that are necessary in order to initialize the library in preparation for a specific set of data. One of the calls tells the library to allocate some memory and then perform whatever initialization is required. This particular API call returns a pointer to char (char*) that is later used as an argument for a few other API calls. My question is... Is there a way, or maybe some kind of trick, to tell exactly how much memory was allocated? It doesn't matter whether or not the solution (if there is one) is C++ related, or some series of OS commands. FYI: We're running on Redhat Linux 6.2 and using GNU C++ 4.4.6.
View 5 Replies
View Related
Jan 31, 2015
So, it seems I have a bug in my code:
Code:
char *mem = malloc(9), *bottom = malloc(3), *in = "abc";
int position = 2, i;
mem = "onetwo";
printf("OLD mem = %s
", mem);
[Code]....
What I'm trying to do is insert "abc" in the 3rd position of "onetwo". Results would be "oneabctwo", but all I get is crashing.
View 9 Replies
View Related
Jul 14, 2013
I have declared a global variable as pointer. The program performs certain number of iterations. After every iteration, the size of memory required for the pointer changes and this pointer variable is to be accessed by different functions. Now, here is my doubt:If I allocate the memory for this global variable in a function, will the contents of the memory be lost once I exit that function. In my opinion, it should not be the case as the dynamic memory allocation takes place in "heap" and should not be affected by the call of functions.
View 4 Replies
View Related
Oct 17, 2014
Code:
int *p, ar[100];
p = (int *)malloc(sizeof ar);
.. *p is a pointer variable, but what means another * here --> (int *)?
View 3 Replies
View Related
Sep 18, 2013
I have created a database for music cds:
Code:
#include<stdio.h>
#include<stdlib.h>
#define array
typedef struct cd_database
[Code]....
When I am using malloc instead of arrays the code is not working properly after exit. I have tried alot but can't came up with a way
View 5 Replies
View Related