C++ :: Converting UNIX Code To Windows

Aug 15, 2013

trying to convert some C++ code written for LINUX/MAC to run on windows. I think signal handling is not as developed for Windows but the error I am getting is that the struct I am trying to use is undefined. I have #include <csignal> at the top and the line giving the problem simply says "struct signal act;". Any pointers or is signal a LINUX native command?

View 2 Replies


ADVERTISEMENT

C/C++ :: Converting 2D Array Code To Malloc

Mar 2, 2015

I made a program that adds two matrices and displays their sum with a max dimension of 100.

/* This program asks the user for 2 matrices called A and B, as integers,
and displays their sum, C. The max dimension of each matrix is 100. */

#include <stdio.h>
// Construct function
void construct() {
int m, n, i, j; // Variables
int first[100][100], second[100][100], sum[100][100]; // Matrices variables

[Code] ....

Now I need to change it so there is no max size for each matrix. The arrays will be larger than 100x100 so I need to use malloc to create my arrays. So I cant use int A[rows][cols]. This is what I did to covert arrays to malloc. It compiles but it crashes after I entered all the integers.

/* This program asks the user for 2 matrices called A and B, as integers,
and displays their sum, C. The max dimension of each matrix is 100. */

#include <stdio.h>
#include <stdlib.h>
// Construct function
void construct() {
int m, n, i, j; // Variables
int *first = NULL;

[Code] .....

View 8 Replies View Related

Visual C++ :: Converting Code To CLI Form Application?

Jun 10, 2013

As a starter project I want convert a Neural net app from "AI Techniques for Game Programming (2002 Buckland)" to a Visual C++ CLI Forms application. I have created the interface and now I have to rewrite the in/output routines, amongst other things.

First question I have has to do with variable initialization used by Buckland. Code looks like this:

Excerpt from header file (CNeuralNet.h):

//-------------------------------------------------------------------
//define neuron struct
//-------------------------------------------------------------------
struct SNeuron
{
//the number of inputs into the neuron
int m_NumInputs;
//the weights for each input
vector<double>m_vecWeight;

[code]....

Question I have: what is the the function of ": m_NumInputs(NumInputs+1)" after the method declaration? Buckland does this in many places in his code. In this case it's a struct, but he does it with classes too.

View 3 Replies View Related

C/C++ :: How To Use Windows Command-line Commands In Code

Sep 18, 2012

In Windows, if you open a command prompt, there are a bunch of keywords like, 'chdir', 'copy', ...

What I'm trying to figure out is how to use that COPY command in c++ code. I want to use the COPY command with the options (/a, /b, ...).

View 3 Replies View Related

Visual C++ :: Getting Exceptions On Windows 7 And 8 On Different Parts Of Code?

Feb 25, 2015

I'm Getting exceptions on Windows 7 and Windows 8 on different parts of the Code? Why this can be happening, why the difference in behavior?

View 6 Replies View Related

C# :: Windows Phone 8.1 Auto Lock Screen Code

Mar 6, 2015

Auto lock screen coding for windows phone 8.1.

View 2 Replies View Related

C++ :: How To Install Glew For Code Blocks On Windows Vista

Apr 29, 2013

I downloaded glew 1.9.0 files and dragged the lib, include, and bin of the glew into the mingw folder within Code Blocks. I don't know if this is the right thing to do I don't understand how this stuff works. Anyway, I tried to compile my openGL 3.0 program that uses glew and I got this error: The procedure entry point _glewBindArray could not be located in the dynamic link library glew32.dll, How do I install glew properly?

View 1 Replies View Related

Visual C++ :: CryptUnprotectData Failing When Code Compiled On Windows 7?

Sep 24, 2012

I have a C++ code that reads the database password from the registry and decrypts it using CryptUnprotectData. We have to deploy this application on a Windows 7 machine.

When I compile my code on Windows XP and run it on the test Windows 7 machine, it works absolutely fine. When I compile the same code on my laptop having Windows 7 and run it on the test Windows 7 machine, CryptUnprotectData fails with GetLastError() return '87'. If I run this application on my own laptop with Windows 7 on it, it again works fine probably because my laptop has a lot of things installed including Visual Studio and all the service packs etc.

I believe I have missed out installing some dependency on the test Windows 7 machine but I am unable to figure out what is that. What is it that's making the Windows XP compiled code running fine on the test machine and not the code that's compiled on Windows 7.

Here is the call to CryptUnprotectData in the code:

if (CryptUnprotectData(
&cipherText,
NULL,
NULL, // Optional entropy
NULL, // Reserved
NULL, // Optional PromptStruct
CRYPTPROTECT_UI_FORBIDDEN,
&plainText))

[code]....

View 10 Replies View Related

C Sharp :: How To Code Array In Windows Form Using Listview In Visual Studio 2008

Oct 5, 2013

This is my problem in my subject programming but i dont how to use Array in windows form ... If i run my code i want my Data in listview would not be disappear if i close the form ...?

View 1 Replies View Related

C :: Program That Does UNIX Strings

Jun 4, 2014

I am not a programmer, C-wise. Mainly a shell scripter. any C program that I can use that can work like UNIX strings | grep "pattern"...At the moment, on a binary file, I am using UNIX strings and then grep for a pattern and print out that line and does some awk -F":" thing. This is manageable for when the binary file is 50M but not for where files are 100M and above. I mean it still works but takes longer since strings work on the entire file.

Basically the information that I am trying to extract from the binary file is some type of header that is contained in a file. I am thinking of maybe writing a 'simple' C program that will read the first few bytes of the binary file and then print the line that contains the string that I am looking for. I don't believe the header is at the end of the file but more in the beginning. I am wanting to extract the header information to be able to rename or make a copy of the binary in a more user-friendly name.

Any good reference/link to a sample program on reading a binary file maybe. Main reason why I am wanting a C program is because the binary file can be on Windows or *nix.

View 2 Replies View Related

C# :: Convert From Datetime To Unix Time?

Sep 1, 2014

I am converting unix timestamp to datetime format like this:

static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
static readonly double MaxUnixSeconds = (DateTime.MaxValue - UnixEpoch).TotalSeconds;
public static DateTime UnixTimeStampToDateTime(double unixTimeStamp) {
return unixTimeStamp > MaxUnixSeconds
? UnixEpoch.AddMilliseconds(unixTimeStamp)
: UnixEpoch.AddSeconds(unixTimeStamp);
}

use it:

Console.WriteLine("From UNIX do datetime 1300123800440 : " + UnixTimeStampToDateTime(1300123800440));

output: 14.03.2011 5:30 PM

Now i would like to have function which convert it back to unix timestamp but unfortuently my new function is cutting down last 3 digits for instance:

public static long UnixTimestampFromDateTime(DateTime date) {
long unixTimestamp = date.Ticks - new DateTime(1970, 1, 1).Ticks;
unixTimestamp /= TimeSpan.TicksPerSecond;
return unixTimestamp;
}

after use of it i am retrieving:

Console.WriteLine(UnixTimestampFromDateTime(Convert.ToDateTime("14.03.2011 5:30 PM")));

result:

1300123800

View 14 Replies View Related

C :: Segmentation Fault While Accessing DAT File In Unix

Oct 28, 2014

Below is my sample code of a C program. I am doing lot of processing, but my issue is I am getting a segmentation fault error in my main when I am putting the file names at the command line and using them. The program works great in Windows, but its giving error in Unix.

Below is the code of my Main function.

Code:

int main(int argc, char *argv[])
{
FILE *user, *requests;
char c;
user = fopen(argv[1], "r");
requests = fopen(argv[2], "r");
//For users
struct userStorage *USHead = NULL;
//struct users *userHead = NULL;

[Code]...

View 6 Replies View Related

C++ :: Debug Multithreaded Application In Unix Environment?

Mar 3, 2013

How can we debug the multithreaded application in unix environment?

View 1 Replies View Related

C/C++ :: How To Calculate NTP Timestamp To Unix Epoch Time

Mar 18, 2015

I have been trying for several months to create a simple SNTP single Client/Server based on RFC5905. Finally I manage to make it work at least I think it works correctly, but when I tried to test my code against a real NTP server (e.g. 0.se.pool.ntp.org:123) the timestamps that I am receiving need to be recalculated. I have tried several different approaches but no matter for 3 days now but no matter what I tried nothing yet.

The problem that I am having in not so much programming error is more about knowing how the NTP server operates.

How to convert the NTP timestamp to Unix epoch timestamp?

Syntax to execute the Server e.g. ./server 127.0.0.1:5000 and Client e.g. ./client 127.0.0.1:5000

Syntax to execute the Client against a real NTP server e.g. ./client 0.se.pool.ntp.org:123

Sample of working code Client:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>

[code]....

Sample of printed output when I use Server and Client.

Reference Identifier 0 LOCL
Reference Timestamp 0.0 1426637081.3564398733
Originate Timestamp 1426637087.3570333925 1426637087.3570333925
Receive Timestamp 1426637087.3570334078 1426637087.3570334003
Transmit Timestamp 1426637087.3570333925 1426637087.3570334046

Sample of printed output when I am probing a real NTP server (e.g. 0.se.pool.ntp.org:123).

Reference Identifier 0 $
Reference Timestamp 0.0 3879449560.3503094062
Originate Timestamp 1426637090.3573978972 1426637090.3573978972
Receive Timestamp 1426637090.3573992772 2722083800.781009125
Transmit Timestamp 1426637090.3573978972 2722083800.937312997

View 2 Replies View Related

C :: Program To Check For Running Pid Using System Call In UNIX / Linux

Dec 11, 2013

I have written a program which uses a pid to check if the process is currently running and return a value based on the system call result.But the program core dumps

Code:

#include <stdio.h>
#include <string.h
int main( argc, argv )
int argc;
char * argv[];
{
int p_pid = 99;
char buff[1000];
}

[code]....

What is the mistake in this code and is it portable in both unix/linux , is the method secure (grepping for program name )?

View 6 Replies View Related

C/C++ :: Know That Data Written To Shared Memory Segment In Unix Is Stored Properly

Mar 8, 2012

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 Related

C :: Print Out - Array Code And Pseudo Code?

Apr 15, 2013

I have assignment which requires me to print out and array code and a pseudo code. I dont no what a pseudo code is,.

View 2 Replies View Related

C++ :: Reducing Code Duplication From Common Code Calling Common Class

Apr 13, 2014

I have a class 'A' which is almost perfect for my needs. Class 'B' uses class 'A' I've now designed Class 'C' and Class 'D' and noticed that there is a good chunk of code in class 'B', 'C' and 'D' for using Class 'A' is duplicated. I've separated out this code in specific, standalone functions in each of the classes. Now I'm wondering where this code should go. At the moment, the functions are duplicated in the three calling classes (B, C and D). Placing the functions into class 'A' would break the single responsibility principle. Inheritance to add functionality would likely break both SRP and LSP. The one that seems that it may work is composition.

However, Is designing a complete class just for a few functions over kill?

Would it be valid for classes 'B', 'C' and 'D' to access both the new class 'E' (which would depend on A) and the old class 'A' (which would have to be the same instance as the instance in the new class 'E'), or should the new class 'E' provide sufficient functionality so that Classes B, C and D don't need to access Class A directly? It would seem that its then an incomplete interface of the original object with additional functionality (ie, incompatible) Or should I do it a completely different way?

View 4 Replies View Related

C++ :: Converting Int To Char

Feb 20, 2014

Why is this

Code: fFile << (char) (i)p.x, (char) (i)p.y,(char) (i)p.z); not the same as this

Code: printf("%c%c%c", (i)p.x, (i)p.y, (i)p.z);

View 13 Replies View Related

C++ :: Converting Text To Hex

Jan 3, 2013

From my tests I found the problem to be somewhere in the Mantissa part that converts it to binary.

bool xsDLL GetHexFromSF_IEEE754( void* to, Text from, ui08 tSize ) {
from.UpperCase();
int db = 0, dB = 0, dBEnd = tSize, dBLast = ( tSize - 1u ), dbEnd = dBEnd * 8;
ui08 *data = reinterpret_cast< ui08* >( to );
for ( ; dB >= 0; --dB )
data[ dB ] = 0u;

[Code] ....

Adjustments made, still having problems though. After finding a more useful resource [URL] ..... I got the function looking more like it should but am still having problems...

View 1 Replies View Related

C++ :: Converting One Format To Another?

Apr 7, 2013

I am in a c++ class and my group is having a hard time making this work... It keeps saying that 'fileOne.open' isn't working.

#include <iostream>
#include <string>
#include <fstream>

[Code]....

View 3 Replies View Related

C++ :: Converting Char To Hex

Nov 8, 2014

Having trouble converting char to hex.

according to here [URL] ....
ô in decimal is 147 and print ô using alt 147

and here [URL] ....
ô in dec is 244 but prints ⌠ using alt 244

put on console

char c = ô;
cout << (int)c << endl;

prints -109 and print m using alt -109

I am using alt to test char output. Why I'm getting a negative value? Which of the tables are correct? I have string of char that I want to print in hex. I get a hex string but the hex value don't correspond to any of the two tables on the websites because the console converts special char to negative values.

View 2 Replies View Related

C++ :: Converting CString To Int?

May 16, 2013

I am having problems with converting a CString to an int and than doing checks on the int to see if it is in a particualr range.Below is what I am doing.

CString numstr = "28"
int num = atoi(numstr);
BOOL valid = TRUE;
if(num < -32,768 {
valid = FALSE;
}

For some reason when running the above code the if statement is executed but it should not be becasue 28 is not less than -32,768. Why this is happening, I am not seeing the reason for this at all!! The num variable is being assigned the correct value.

View 5 Replies View Related

C++ :: Using Signals On Windows

Oct 12, 2012

I'd like to compile following code:

Code:
sigfillset( &sa.sa_mask );
sa.sa_handler = &CDevice::PipeHandler;
sa.sa_flags = 0;
sigaction( SIGPIPE, &sa, NULL );
sa.sa_handler = &CDevice::TerminatorHandler;
sigaction( SIGQUIT, &sa, NULL );
sigaction( SIGINT, &sa, NULL );

Using MSVC 2010 to run on Windows 7. Is it possible?

View 1 Replies View Related

C++ :: How To Use Drand48 For Windows

Jul 2, 2012

Here are the libraries included:

#include <iostream>
#include <cmath>
#include <cstdlib>
#include "stat.h"

And heres the line being flagged:

d=ttl*drand48()-fit[0]; //intialize to reigon for first entry

The error I receive is one discussed on a number of different forums:

C:Documents and SettingssarabrownDesktopSarahScheduling Codestat.cpp|181|error: `drand48' undeclared (first use this function)|

C:Documents and SettingssarabrownDesktopSarahScheduling Codestat.cpp|181|error: (Each undeclared identifier is reported only once for each function it appears in.)|
||=== Build finished: 2 errors, 1 warnings ===|

It just seems to me theres a lot of conflicting information about if this is even possible to do on Windows and when I do try work around functions or calling double drand(void) I get a ton of errors. I'm hesitant to try rand() or something less precise. I was hoping maybe someone would be able to maybe suggest a compiler which will run this or a different library, right now I'm using Code Blocks IDE.

View 1 Replies View Related

C++ :: Converting Strings In Application

Jun 8, 2014

I am having trouble converting strings in my application.

This is the code that is eventually getting called, the first parameter takes a LPCWSTR

Code:
hr = m_pGraph->RenderFile(m_filePath, NULL); // takes LPCWSTR This is where the trouble begins.

The compiler shows that sResult is proper but after I try to convert a std::string to a wchar it prints garbage

Code: const wchar_t* m_filePath = (wchar_t *) oDb->GetNext().c_str();

Code:
std::string CSqlLiteDatabase::GetNext() {
sqlite3_stmt *oStmt = nullptr;
std::string sql = "SELECT path || filename FROM table WHERE id = 1";
char message[255];

[Code] ....

View 6 Replies View Related







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