C/C++ :: Conditional Multiple Entry Points?

Nov 16, 2014

I'm playing with my final year project, building a game boy emulator in C, and I wanted to try out something to streamline my code base. I'm building against Win32, GNU C and Googles Native Client.There are no platform specific headers or functions in use. What I'm trying to do is have a file that conditionally includes the entry point (so _tmain for Windows etc) based on a preprocessor directive being set/not-set.

[note] I realise I could write both entry point classes in one file and use the preprocessor directive in there, but it's not as neat as a single file calling in one or the other. I figure this should work because I can conditionally include headers for Win/NaCl (providing the signatures match, of course).

View 3 Replies


ADVERTISEMENT

C/C++ :: Find Maximal Points Among Given N Points

Nov 3, 2014

Example: In a 2-D space, point A=(a1,a2) is bigger than point B=(b1,b2), if a1>b1 and a2>b2.

How do I write a presudo code to find all the maximal points among the given n points?

View 14 Replies View Related

C :: How To Use Conditional Operator

Jan 25, 2013

i know

Code: (condition) ? true-clause : false-clause

but how do you use an array as the condition, how will the code look?For example i want to write

Code:

string numbers[5] = {"one","two","three","four","five"};
numbers == "one" ? thumb : again; thumb and again will replace something else. Don't worry about them.

how do i say that if the numbers array is representing "one" then it replaces as "thumb", otherwise "again".

View 5 Replies View Related

C++ :: Nested Conditional Operations

Feb 4, 2014

So I think I am having syntactical problem with my code.

Code:
int main() {
vector<int> ivec;
int score;
[Code] ....

I get an error from my compiler on the ?10th? line (Nested condition line) that says |19|error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'|

The purpose of the program is to take input and store it in a vector and then change the value to be between 1-6. I made this for the purpose of learning about nested conditional operations.

View 3 Replies View Related

C++ :: Getline As Conditional Of While Loop

Aug 1, 2014

I am trying to use getline as the conditional for a while loop as seen below.

string filename, guard_name;
int call_number;
vector <Seniority> SeniorityList;
ifstream SeniorityFile;

[Code] ....

However, when I compile the code, I get the following error message on the line with the while loop.

error C2780: 'std::basic_istream<_Elem,_Traits>
&std::getline(std::basic_istream<_Elem,_Traits>
&,std::basic_string<_Elem,_Traits,_Alloc>
&)' : expects 2 arguments - 3 provided

The program will be reading in a .csv file, so I need my program to be able to deal with values separated by commas. Is there a reason why it will not accept that conditional statement?

View 3 Replies View Related

C++ :: UDP Protocol In A Conditional Statement?

Nov 4, 2013

I'm facing a serious problem with udp protocol. I have Master & Slave devices.I did implement the class as the follow pseudo code states

In Master side

while (true)
{
1-send data to slave;
2-get data from slave;
3-apply force;
}

In Slave side

while(true)
{
1-get data from master;
2-if (collision happnes)
send force to the master
}

the problem is in line 2 in Master side. Once I include the line I can't send or receive data. What do you think the problem is?

View 3 Replies View Related

C# :: Valid To Use And / Or When Using Conditional Operator

Jan 31, 2014

I want to know if it's valid to use and/or when using the conditional operator.

Example:

value = textBox1.Text;
decimal? qty = (value.Equals("0") || value.Equals("0.0")) ? null : (decimal?)decimal.Parse(value);

View 2 Replies View Related

C++ :: Declaring Variables (Conditional) At Runtime?

Jan 22, 2014

I am looking for a way to declare variables at run time which being a static language shouldn't happen. I will explain my situation.

I am upgrading a legacy program that modifies executables (non malicious). I am trying to add 64bit support.

It is a huge project and I understand the majority of it but my issues with how it handles the input data.

It has a struct that certain parameters of the input file is loaded into:

Code:
typedef struct DATA {
DWORD Size;
IMAGE_NT_HEADERS32 Headers;
} _DATA; *PDATA
etc, etc its a huge list.

My problem lies in the fact that I need to change IMAGE_NT_HEADERS_32 to IMAGE_NT_HEADERS64 at runtime.

That DATA struct gets called at least 110 times during runtime.

How I might tackle this? Having a conditional statement repeated that many times seems ridiculous.

View 6 Replies View Related

C++ :: Newline Character Not Being Picked Up In A Conditional Statement

Jan 15, 2014

I have the following code:

Code:

while (lineread != "
")
{
getline(ifs,lineread);
}

In essence, it reads an input file, line by line until it hits a line only containing a newline character. So if the input text file is:

27
GC0123456
102905908801170--
2034068010201360
3039077011601400
4043086012901400
504709401400
6051010101400

[code]....

It should exit the while loop after hitting line 6. What happens however is that it goes into a perpetual loop and doesnt exit the while loop upon reading line 6.

What I did was changed the code to:

Code: while (lineread != "*")
{
getline(ifs,lineread);
} and the input file to:
27
GC0123456
102905908801170--
2034068010201360
3039077011601400
4043086012901400

[code]....

and finally it stops after line 6. In this case, merely changing the " " conditional character to a simple asterisk character "*" fixes the problem.

However I wish to keep the input text file as is with the newlines, so how do I make it exit the while loop when detecting a as a line?

View 3 Replies View Related

C/C++ :: (OpenGL) Drawing Not Updated When There Is Conditional In Code

Aug 1, 2014

I'm making a program to draw a trajectory, was using as a basis the tangent, but when I put 90 degrees, the tangent is very large, so I thought of putting an if (angle == 90) did not use the tangent.

the design is right, but after choosing it 90 degrees it stops to draw.

for example

1-30 degrees - draws
2-45 degrees ---- draws
3 draws -90 degrees ---
4-60 degrees --- not drawing
5 --- 80 degrees --- not drawing
*
*

making routine design is presented below:

void Draw() {
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_LINES);
convert(graus);
if (ant){
x=xx;
y=yy;

[code]....

View 4 Replies View Related

C/C++ :: Conditional Jump Or Move Depends On Uninitialized Value(s)

Nov 24, 2014

I am getting this message from Valgrind, As far as I can see what it points to is initialized. The memory it is referring to is freed in unload and I was not getting this error until after I added the check function. Valgrind was happy. Here is the code and the error message from Valgrind. I am trying to create a spell checker for an assignment for a online class I am taking. I just want to get this table working correctly before I add it to the rest of the program. The code seems to run fine but I have come to see that dos not mean much in C.

#include "hashTable.h"
#include <stdbool.h>
table_node hash_table[TABLE_LENGTH];
bool loaded = true;
//assigning letters a-z to table nodes for buckets
void key_hash_t( )

[Code] ....

Valgrind error:

arortell@gentoo ~/Development/Projects/C_Projects/Data_Structures/HashTable $ valgrind --leak-check=full --track-origins=yes ./hashTable
==11360== Memcheck, a memory error detector
==11360== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==11360== Using Valgrind-3.9.0 and LibVEX; rerun with -h for copyright info
==11360== Command: ./hashTable

[Code] ....

View 10 Replies View Related

Visual C++ :: Conditional Compilation Based On Whether It Is Windows 7 Or 8?

Apr 10, 2013

I want to do conditional compilation based on whether it is windows 7 or windows 8. Here is the code below.

#if (_WIN32_WINNT >= 0x0602) //Condition to check whether it windows 7 or 8 .Based on this we can load msxml 3 or 6.
#import <msxml6.dll>
#else
#import <msxml3.dll>
#endif

Im building the above code in windows 8 machine.

Issue here is _WIN32_WINNT should have a value 0x0602, it means it is running in windows 8 machine.Instead it has a value 0x0601 (Means it is taking windows version as windows 7 defined in sdkddkver.h).Im not sure after installing windows 8 sdk im not able to see any include or lib files in the path below C:Program Files (x86)Microsoft SDKsWindowsv8.0A . but i can see all include and lib files of sdk version v7.0A available although i did not installed it.

View 5 Replies View Related

C++ :: Conditional Jump Depends On Uninitialized Value Valgrind

Jan 10, 2013

I have airport class which should navigate planes, in its list to runways, with method move, theres a method prepare which changes the direction of flight to all planes, always before move is called, move just increments decrement x and y of plane in its list. But after calling two times in row airport->move(), I get screwed and I really dont know wheres the problem. Have I badly initiazed something? Iterator gets invalidated.

Valgrind Stacktrace
Conditional jump or move depends on uninitialised value(s)
==26207== at 0x409601: plane::move() (in /home/xnovak11/Downloads/airport/main)
==26207== by 0x401FBD: airport::move() (in /home/xnovak11/Downloads/airport/main)
==26207== by 0x405FE1: io::start(std::istream&, std:stream&, std:stream&) (in /home/xnovak11/Downloads/airport/main)

This is how I add planes into list in airport

Code:
list<plane*> planes;
list<plane*>::const_iterator planeIterator;
list<plane*>::iterator planeIteratorMoj;
bool airport::addPlane(const plane& p) {

[Code] .....

This is the method where it fails. When I call it once, no problem, after second call I get instead of normal number in cout<<after move<< s1 i get like 8795456 ....

Code:
void airport::move() {
for(planeIteratorMoj = planes.begin(); planeIteratorMoj!= planes.end(); planeIteratorMoj++) {
plane * p1 = (*planeIteratorMoj);
int s,w;
p1->getPosition(s,w);

[Code] .....

View 3 Replies View Related

C++ :: Adding Entry To Map?

Feb 5, 2013

I have the following code in sourceFile.cpp. functionA() is first called and inserted entires for key1, key2 and key3. Then functionB() gets called to use the vectors for the 3 keys. I want to free all memory after exiting functionC(). Among the three ways to put an entry into the map for the 3 keys, which is correct / better?

Class ClassA { ... }
ClassA *key1 = new ClassA();
ClassA *key2 = new ClassA();
ClassA *key3 = new ClassA();

[Code]....

View 2 Replies View Related

C/C++ :: How To Create Entry Verification

Nov 21, 2014

I have an assignment to create a program that will display the duplicate numbers that were entered by a user. I have the code finished and I have covered the basic requirements of the assignment. However, during my testing I found that if I enter anything other than a whole number (i.e. char or float) the program will run out and exit. I would like to add a little code to verify that the user has entered a whole number. I cannot seem to get this to work though. I have written other codes that verify if a number is above and below a certain value, I just do not know how to look for a certain type of entry.Here is my code:

int main() {
int number[20];
int duplicateNumber[20];
int i, j, k, counter = 0;
// Get number input from the user
for (i = 0; i < 20; i++) {
printf("Please enter a whole number %d: ", (i + 1));

[Code]...

View 3 Replies View Related

C++ :: Displaying Average For Each Entry

May 3, 2013

I have to display an average for each student that is entered ....

void StudentData::displayAverageScore() {
double totalScore = 0;
double totalEx1 = 0, totalEx2 = 0, totalEx3 = 0, averageScore = 0;
for(int i = 0; i < entries.size(); i++) {
totalEx1 += entries[i].getEx1();// accumulate totals
totalEx2 += entries[i].getEx2();
totalEx3 += entries[i].getEx3();
if(totalScore != 0) averageScore = (totalEx1 + totalEx2 + totalEx3) / 3; // don't divide by 0
cout << "Average Score For Exams: " << setprecision(1) << fixed << averageScore << endl << endl;
}
}

View 7 Replies View Related

C++ :: Adding Entry Into Array?

Aug 6, 2014

My program is suppose to be as a virtual phone book that allows you to add,search, display names and numbers.

At the beginning you are able to add up to 10 entries and then from there the program goes to a menu where you can add more entries, search etc.

My problem is that I am unable to add an entry into the existing list of names/phone numbers.

Example: At the beginning I add Joe,Albert,Barry. It sorts them into Albert, Barry, Joe (good so far!)

However, if I choose to add another entry (Carl) it becomes Barry,Carl,Joe.

The functions I am using to add entries are: GetEntries (for initial entries) and Addentries for more entries during the main program.

*******************************COPY OF CODE**********************************

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

[Code].....

View 5 Replies View Related

C++ :: Makefile Only Executing First Entry

Mar 15, 2013

Why this makefile only executes the first entry, compiling only the first program listed?

###########################################################
#
# Simple Makefile for Operating Systems Project 2
#
###########################################################
vowcon:
g++ -o vowcon vowcon.cpp -pthread
osproj2c:
g++ -o osproj2c osproj2c.cpp -pthread
osproj2b:
g++ -o osproj2b osproj2b.cpp -pthread
osproj2a:
gcc -o osproj2a osproj2a.c -pthread
clean:
rm osproj2a osproj2b osproj2c osproj2d vowcon

View 7 Replies View Related

C/C++ :: While Loop To Stop After Third Entry

Jul 6, 2014

Having multiple issue trying to get a while loop to stop after the third entry.

#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
using namespace std;
int mySequentialSearch() {
int value;
string line;

[Code] .....

I am just working on the while loop right now. Then the function after I get the loop working.

View 10 Replies View Related

C :: Secure Entry Keypad Simulator

Feb 15, 2015

We've been tasked write a code which would mimic a secure entry keypad.. Only recognising the digits 0-9 for the passcode, and non-numerics S (start again) C (clear last digit) and E (enter) for the control. All other key strokes are to be ignored.

The passcode has to be <10 digits and represented on the screen by "****", with any keystrokes >10 ignored.
The valid passcode being 4 digits (1234).

With 3 attempts to get the correct pass code, after each fail attempt as please try again message show, where after the 3rd attempt a specific message is displayed and an alarm sounds..

View 13 Replies View Related

C :: The Last User Entry In Loop Fprintfed Twice?

Apr 13, 2014

Still working on my first homegrown C program design . The function basically allows the user to enter a list of classes and grades and saves the list to a file to be used later in the file. The function compiles and runs through without error except for the fact that it always prints the last user entry to the *profilep file twice. Just as a note, the scanchar function is one I made to scan in one character and an end of line character to throw away the end of line char before I learned about %*c about 30 minutes ago...

Also I haven't much bothered to strengthen the function against crazy user input but I have heard using fgets and sscanf in conjunction can replace scanf and protect against weird user input. How to apply this within the program.

Code:
// creates a new profile and prints it to the profile file.
void newprof(FILE* profilep, const char *allclasses[ABBR_SIZE]){
int c, checker, counter;
int i, a;
char prof[MAX_PROF][ABBR_SIZE];
char grades[MAX_PROF][3];

[Code] .....

View 1 Replies View Related

C++ :: Error 453 - Can't Find DLL Entry Point

Nov 7, 2013

Using VC++ 2010 Express. I am creating a dll to export a simple Multiply function so I can use it in Excel/VBA

These e are the steps I am following :

. Create a Win32 C++ Project and give a name. For example: CallDllFromVBA
. Select the DLL option in the Wizard and click Finish
. In the CPP file (here CallDllFromVBA.cpp), add the following code

#include "stdafx.h"
int _stdcall Multiply(int x, int y) {
return x * y;

[Code] ....

The Build output show everything is ok as follows :

CallDllFromVBA.cpp
CallDllFromVBA.vcxproj -> c:documents and settingsadministrateurmes documentsvisual studio 2010ProjectsCallDllFromVBADebugCallDllFromVBA.dll
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

In VBA, I insert a module and add the following code:

Declare Function Multiply Lib _
"c:documents and settingsadministrateurmes documentsvisual studio 2010ProjectsCallDllFromVBADebugCallDllFromVBA.dll" _
(ByVal x As Long, ByVal y As Long) As Long
Sub test()
MsgBox Multiply(2, 4)
End Sub

When I run the Test sub I get the error: 453 - Can't find dll entry point

I also opened the CallDllFromVBA dll with Dependency walker and I can't find the Multiply export function - In fact, the dependency walker doesn't show any function exports at all for the CallDllFromVBA dll !

View 2 Replies View Related

C++ ::  Passing A Polymorphic Array Entry

May 31, 2013

I'm having an issue during the linking stage of the .exe during compile time, and it's because of a call to a function with a polymorphic parameter.

//here's how the classes are setup
class grandpa {};
class mom public grandpa{};
class dad public grandpa {};

[Code]....

dad has sons in the vector and mom has daughter in the vector. What I want to do is have a function that can accept either of these vectors as one parameter like so: void func(const grandpa* aObject);

Finally, I have an error when I pass an object to the function like so: func( d[0] );

View 1 Replies View Related

C/C++ :: Modifying Row Of Matrix Based On Zero Entry?

Nov 19, 2014

Here is the problem:

Write an algorithm such that if an element in an M * M matrix is 0, its entire row and column is set to 0.

Your function prototype may look like the following:

void setZeros ( int size, int arr[][size] );

Heres what I have:

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define SIZE 3
void scan_matrix(int arr[][SIZE]);
void print_matrix(int arr[][SIZE]);
void initiailize_matrix(int arr[][SIZE]);
void set_zeros(int matrix[][SIZE]);

[code]....

I'm not sure on how to scan zero for this code and I have bolded some comments that I am having trouble with as well.

View 1 Replies View Related

C# :: How To Add Data Entry List In Array

Jan 29, 2014

I'm learning C# and having fun and I've been practicing by working on this little data entry console application. Basically the user inputs first name, last name, age, gender, employee id, then I ask the user if he/she wants to add another entry, if yes then loops back at the top, and if no, it prints out the amount of entries added. The issue I'm having is that the entry list is never kept or stored when adding another entry, it replaces what was entered before which is not what I'm looking for. I don't know how to stuff one entry list information seperately in an array so that I can print out which ever entry the user decides to choose once he/she is done adding entries. Is there a way to make this work?

Here is my program code:

using System;
namespace Ch02_Exercises_12
{
class Program {
static void Main() {
string firstName;
string lastName;
string input;
sbyte age;
char gender;

[Code] .....

View 4 Replies View Related

C/C++ :: Prevent Duplicate Entry When Insert Age

Oct 17, 2014

I created program that insert employes data and then print their data but never accept duplicate age if user entered duplicated age prompt him to enter another age (age must be unique)

Here is my code

#include<conio.h>
#include<stdio.h>
#define size 3
struct emp {
int age,overtime,dedcution,netsal;

[Code] .....

View 1 Replies View Related







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