C :: Calculate Offset Of Simple Program

Sep 28, 2013

I would to learn how could i calculate the offset of simple c program?

Lets say that I have that simple program:

Code:
#include <stdio.h>
int main() {
int x=1;
printf("x = %d", x);
return 0;
}

View 9 Replies


ADVERTISEMENT

C/C++ :: Calculate Offset Of 3dD Array?

Apr 1, 2014

Is this the correct way to calculate the offset of a 3d array? Also is the dynamic allocation for it in the main program correct?

Some how it's not working fine after I input the values for some values of x,y,z e.g when the const ints are 2.

#include <iostream>
using namespace std;
const int x = 2;
const int y = 2;

[Code]....

View 8 Replies View Related

C++ :: Calculate Simple Interest Using Functions

Jan 17, 2013

I was trying to make a program of calculating simple intrest using functions. I don't know whats wrong with the program but it always shows a wrong output.

#include<iostream.h>
#include<conio.h>
float si(int p,int r,int t) {
return ((p*t*r)/100.0);

[Code] ....

View 4 Replies View Related

C++ :: Calculate Simple Interest Of Given Loan Amount And Duration In Years

Jan 25, 2013

Your objective is to write a program that calculates the simple interest for a given loan amount and duration (in years).

Formula:

Simple interest = loan amount X interest rate X number of years
Assume interest rate is a constant 6% per year.

Specifically, your program will:
1. Output descriptive header
2. Prompt and read any customer’s first name, middle initial, and last name individually
3. Prompt and read the principal/loan amount
4. Prompt and read the duration of the loan in years
5. Calculate the interest
6. Output:
a. Customer full name
b. Principal/loan amount
c. Duration of loan
d. Interest rate
e. Interest on loan
f. Principal and interest due at end of term

OK SO THIS IS MY PROGRAM SO FAR. As you can see i got it all but i am so confused with as to for loan amount and duration of year, if i should use float or double to declare it?

i need to finish this assignment by calculating the simple interest and i dont know how or where to begin.

int main(){
system("color f0");
string firstName;
string middleInitial;
string lastName;
cout<<"Please enter your First Name: ";

[Code]...

View 1 Replies View Related

C++ ::  Looping Simple Menu - Calculate Dimensions Of Floor Plan In Square Feet?

Oct 2, 2013

What I'm trying to accomplish is to ask the user what their floor plan is (in square feet), have them pick what kind of material they want and give them a general price.

Which is working out great so far, but I would also like to add a loop at the end that cycles back if they want to re-do the estimate with a different material selection and if not exit out the program.

I've been trying do while and if/else loops but i can't get them to work right.

#include <iostream>
#include <string>
using namespace std;
int main() {
string custName, selection;
int custNumber, floorSize, material, contactSystem;

[Code] ....

That's basically what I've come up with so far minus all the erroneous attempts. Though as is I technically complete the assignment, I would like the extra credit from making the last part loop.

View 1 Replies View Related

C/C++ :: Offset Function Inside Class?

Jan 1, 2013

i usually use this method for accesing functions in executables, the code is executed from a DLL (always works, except when the function are inside of a class, even tho is public):

.h:

typedef int (*pgObjViewportClose) (OBJECTSTRUCT* gObj);
extern pgObjViewportClose gObjViewportClose;

.cpp

pgObjViewportClose gObjViewportClose = (pgObjViewportClose) 0x04F1940;

That works, but i can't get it to work if the accesing function is inside of a class, i get Unhandled Exception while trying to access a function inside a class, is there a way to do it?.

View 1 Replies View Related

C++ :: Pointer To Memory At Offset And Length

Aug 26, 2013

I'm working with memory mapped files and I have a block of memory that I've mapped to.

I want to write a function that returns a pointer to a portion of the mapped memory at an offset and length so I can write to it. I've never worked with memory at this level, is what I'm attempting possible?

I know that mapping functions can map to a part of the file at length and offset but I'm not sure if I should make multiple calls to map the memory from the file or just map the memory once and work with the portions I'm interested in using my proposed GetMemory function.

Code:

LPVOID m_lpData;
LPVOID GetMemory(DWORD pos, DWORD length) {
BYTE* buffer = (BYTE*)m_lpData;
buffer += pos;
// how to get a length of the memory?
return ((LPVOID)buffer);
}

View 14 Replies View Related

C++ :: How To Make A Simple Program EXE

Feb 12, 2014

I would like to know how can I make a simple program .exe so that I don't have to open it through code blocks every time.

View 2 Replies View Related

C :: Simple Loop Program?

Feb 27, 2014

3. Write a program that reads a sequence of positive integers and prints out their sum, except that if the same number occurs several times consecutively, ignore all but the first. Assume an input of 0 marks the end of the input. For example, if the input is 3 8 5 5 4 9 1 1 1 1 8 0 then you should print 38 (i.e., ignore one of the 5's and three of the 1's).

View 5 Replies View Related

C :: Simple Program / Null Terminator

Aug 1, 2013

my program is printing out a random symbol afterwards , when trying to copy a sequence of chars into a new buffer.

Code:

#include <stdio.h>#include <stdlib.h>
int tokenCopy(char* dest, const char* src, int destSize);
int main() {
char buff[3];
int n = tokenCopy(buff, "This is a string", 3);
printf("%d '%s'
", n, buff);

[code]....

View 2 Replies View Related

C :: Simple Character Counting Program

Dec 14, 2013

Code:
#include <stdio.h>
int main(){
double nc;
for (nc = 0; getchar() != EOF; ++nc)
;
printf("%.0f
", nc);
}

It works well and I am using ctrl-D as my EOF. Now I understand that C is not really a language for dealing with text, which is why I am learning it more in depth, my degree was in robotics, and I think C is definitely the best place to be for me. So this may just be a quirk, but if I type more than 10 characters, I get the right answer from the program, however, if I type less than 10, for the sake of argument I type Hello and then return, if I at that point do ctrl-D, I get the answer 6D?

The 6 is right 5 letters and a return character, but what is the D?

View 2 Replies View Related

C :: Simple Deadlock Detection Program

May 1, 2013

I'm trying to write a program that detects deadlock. Some of the code I already tested in an earlier stage but at this point when I run the code it somehow gets stuck. I believe that it has something to do with a negative integer value. Anyhow, the program should still work if a negative integer comes up. Here's my code so far.

Code:

#include <stdio.h>
#define FALSE 0
#define TRUE 1
int ALLOC[5][5], REQ[5][5], TOT_RES[5], process, resource, NUMB_RES=5, NUMB_PRO=5;
int TMP[5]={0}, AVAIL[5], CNTR=0, FIN[5]={FALSE}, FLAG;
}

[code]....

The program usually gets stuck after producing output displaying the "Available: " text. After that a list of tabbed numbers should appear, but it doesn't.

View 4 Replies View Related

C++ :: Simple Program To Display Menu With Options

Mar 23, 2014

I decided to create a simple program to display a menu with options, while that is easy enough I had some difficulty when selecting an option that has options inside which also has an option again. While I had many issues in the past I'm finally finished with it and it works fine, but being new to programming and not knowing various other methods available.

Code:
//:::::::::::::::::::::Simple Menu Program::::::::::::::::
//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

#include <iostream>
#include <string>

//function prototypes

[Code] .....

View 1 Replies View Related

C :: Converting Simple Crc32 Program To Octave

May 1, 2014

I have been working on a simple crc32 program in octave and have been using a program already done in C as a guideline. I have been having some problems since octave and C simply do things differently. Right now i have a problem with right shifting.

unsigned int crc = -85
unsigned int x = (crc >> 1);

The resulting x will be 2147483605. I tried putting 0xFFFFFFFF instead of -85 and i got the same result.

If i put -85 for crc in octave, i get a small number -43 which looks more reasonable.

View 1 Replies View Related

C :: Simple File And String Program Not Running

Mar 6, 2015

The assignment is to write a program that statistically computes similarity of C syntax with another program; a same and a different. The one used here is in C language, it's called Battleship.cpp. The program must open a file and read line by line for keywords and then produce statistics. The reason my code is not running is the fopen function is failing and it goes to return -1. I am using MS Visual Studio 2013 and there are no compiler errors after turning off deprecation. I do see, however, this error UMEngx86.dll'. Cannot find or open the PDB file. The file being opened is in my source folder.

Code:
1
2
3
4
5
[code]....

View 4 Replies View Related

C :: Simple Way To Have Instant Communication In TCP/IP Chat Program?

Mar 25, 2014

My program allows a server and a client to chat over a socket. Currently I have to wait for one of them to type a message and press enter, before a message from the other person can be received.

Is there a simple way for messages to be received instantly - but not disturb any message that is being typed in?

View 2 Replies View Related

C# :: Created A Simple Basic Program That Uses Sockets

Feb 22, 2012

I have created a simple basic program that uses sockets but it can only handle one connection, how do I make it so it handles multiple connections?

Server code:

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
}

[code]...

View 5 Replies View Related

C++ ::  Simple Encryption Program Runtime Error

Jul 22, 2014

I am trying to make a simple program for encrypting a char* with the XOR operator. The code compiles and links perfectly, but I get an Access violation runtime error:

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <fstream>
using namespace std;
int main(int argc, char** argv) {

[Code] .....

Text that I am inputting:

My username is memberfunction.

View 9 Replies View Related

C++ :: How To Create Simple Encryption And Decryption Program

Apr 18, 2014

Write a program to do simple encryption and decryption. Encryption basically means to convert the message into unreadable form. In this assignment, it should be done by replacing each letter of a message with a different letter of the alphabet which is three positions further in the alphabet. Then, all the letters will be reversed. Decryption is the process of converting encrypted message back into its original message. Your program should use the following shifting method.

Note: You must use array.

#include <iostream>
#include <string>
using namespace std;

[Code].....

View 2 Replies View Related

C :: Program Doesn't Properly Compute Simple Polynomial

Feb 7, 2014

The program will ask for the user to enter a value for x, then compute the following polynomial: 3x^5 + 2x^4 - 5x^3 - x^2 + 7x - 6.However, when I double check it with my calculator I get a wrong answer for random values of x. To simplify my problem I'm using only integers.

Code:

#include <stdio.h>
int main(void)
{
int x, polynomial;
}

[code]...

View 5 Replies View Related

C :: Creating Simple Calculator By Splitting The Program In 3 Files

Feb 21, 2014

I am new to C programming, I have been given an assignment to create a simple calculator by splitting the program in 3 files. It should have 2 .c files and 1 .h... I went through the internet extensively and could only come up with this.

main.c:

Code:

//Calculator main.c
#include <stdio.h>
#include <conio.h>
#include "Functions.h"
int main() {
float x = 0, y = 0;
int operation;

[Code]...

Functions.c

Code:

#include "Functions.h"
extern float x, y;
float addition (float a, float b) {
return a + b;

[Code]...

Functions.h

Code:

#ifndef FUNCTIONS_H_INCLUDED
#define FUNCTIONS_H_INCLUDED
float Sum(float a, float b);
float difference (float a, float b);
float remainder (float a, float b);
float product (float a, float b);
#endif

When I do a 'cl main.c' on the Developer Command window for VS2013, i get an error that reads :

main.obj
main.obj : error LNK2019: unresolved external symbol _difference referenced in function _main
main.obj : error LNK2019: unresolved external symbol _product referenced in function _main
main.obj : error LNK2019: unresolved external symbol _addition referenced in function _main
main.exe : fatal error LNK1120: 3 unresolved externals

View 5 Replies View Related

C++ ::  Simple Program To Prepare Result Of N Students Using Structure

Jan 17, 2014

This is the program below..can you spot the errors in it.. I am getting lots of errors...!!

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
struct student {
char name[10];
int rollnumber,result
float m1,m2,m3,total

[Code] .....

View 12 Replies View Related

C :: Simple Program To Bubble Sort Values Of A Linked List

Nov 30, 2013

HelI have been tasked with creating a program which (1) takes in integer values from a user (until the user enters -1) and inputs these values into a linked list. This (2)original list is then to be printed out. The program then uses the algorithm "bubble sort" to (3)order the list in descending order before finally printing it out again.

I have managed to do this but I kind of cheated since I do not quite understand how to manipulate a linked list. What did was I took the values in the linked list and transferred them into an array and then did bubble sort on that array.how to do bubble sort on a linked list as well as how to print a linked list.

Code:

#include<stdio.h>#include<stdlib.h>
typedef struct node
{
int info;
struct node *link;

}Node, *NodePointer;
void printList (NodePointer head)
}

[code]...

View 4 Replies View Related

C++ :: Simple Game Menu - Program That Simulates Handheld Gaming System

Sep 26, 2013

I have to write a program that simulates a handheld gaming system. a system can have power toggled so its either on or off. when the system is on, its volume level can be raised or lowerd. a system has minimum volume level of zero and a maximum volume level of 10. a system stores games.

// simple game menu
//simulates a handheld gaming system
using namespace std;
class Game {
public:
Game(int GameNumber = 3, int volume = 10);

[Code] .....

View 1 Replies View Related

C++ :: Program To Calculate BMI

Oct 7, 2013

I'm trying to successfully run a program that calculates your BMI but, although it runs, it is not giving the the correct math. Instead, it gives me the number i've submitted as my weight as an answer. I'm using Visual Studio 2008 and the formula: weight / (height/100)*2

Here is my code

#include <iostream>
#include <cmath>
using namespace std;
int main() {
int weight;
int height;
double BMI;

[Code] ....

View 2 Replies View Related

C++ :: Program To Calculate Fractions?

Oct 24, 2013

I need to write a program that can calculate fractions.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved