C++ :: Handy Function (or Library) For Converting Between Different Text Formats?

Feb 3, 2015

know of a handy function (or library) for converting between different text formats? I've heard of a library called iconv but I've no familiarity with it. However, it looks promising (from what little I can find out about it...)

Specifically, the text %20 is often used in hypertext to indicate a space character - so the string "Hello There" would get changed into "Hello%20There". How can I easily change between one and the other?

Obviously I could use string replacement functions but that'd need me to anticipate every potential hypertext code sequence.

View 5 Replies


ADVERTISEMENT

C++ :: Converting Cmdline Into Normal Function So Can Put Into Library

Apr 23, 2013

I need to convert this code into a normal function that can be put into a library.

Code:

#include <windows.h>
#include <stdio.h>
#include <tchar.h>

[Code].....

Like on line 21&22, I need to get the stuff from within the program, not through cmdline.

View 1 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 Numbers Into Text

Jul 25, 2012

Take a number that is entered by a user and turn that into printed text. Ex. 85 would be eight five. The problem I am having is I'm not quite sure how to go about this. I don't know if I should use an array, string, or something else.

View 12 Replies View Related

C :: Decrypting / Extracting Custom File Formats

Sep 25, 2014

So this may be against the rules, not sure, grey area probably? However I just bought the PC game Oil Rush, and was having a look at how the assets are packed. As with most games the textures, scripts, sounds and audio are all free to access.

However the game data such as maps, models and other, are packed into UNG files, i.e a custom encrypted file format, which probably is also compressed. So I googled for an unpacker/extracter and found one which also comes with the C source. You can download here. [URL] ....

So I am trying to figure out how these authors work out this file format, from the source we have,

Code:
static const u8 unigine_mask[] = "xffx7fx3fx1fx0fx07x03x01";
u32 unigine_key = 0xa13cdbde;

Looks like a password of sorts. You then have to work out the complete understanding of the file formats, headers, blocks etc.. How is this done...

View 4 Replies View Related

C :: User Can Input Phone Number In Any Of Formats

Jun 18, 2013

I'm having a bit issue with ispunct in my function. The user can input a phone number in any of the formats below:

4147778888
(414)7778888
(414)777-8888

The program will only print out:

41447778888

What I am trying to do is accept any integer and parentheses. If the user inputs anything else, the program will display an error message. Right now, parentheses displays an error which is obvious but I'm wondering if there is a way I can allow a parentheses to be entered but not any other symbol. ex: . , : ; " '

Code:
void getPhoneNum(){
// Local Declarations
char string[14];
char* tokPtr;

[Code] ....

View 6 Replies View Related

C++ ::  Logging Namespace For A Game - Method Formats

Mar 17, 2014

I am creating a logging namespace for a game that I am creating. The logging includes a file, and it would contain the following methods:

OUT::log(?)
OUT::warn(?)
OUT::critical(?)
OUT::debug(?)

I will want to call things like

OUT::log("Something happened");
and
OUT::log("Code process " + int proc + " occurred.");

But this might have to be changed to something like
OUT::log("Code process ", int proc, " occurred.");

What would I put in place of "?" to accomplish this?

I don't want to create 30 different methods for this, ie, not

OUT::log(string, int, string);
OUT::log(string, long, string);
OUT::log(string, double, string);
OUT::log(string, int);
OUT::log(string, int, string, int, string);

...I do NOT want to do this...too much chaos. I understand in C++11, I could do something with int like to_string, and that would make the "string" + int + "string" to work.

View 7 Replies View Related

C++ :: Text Adventure Game - Converting Input To Uppercase?

Jul 16, 2014

I'm trying to create a sort of text-adventure game, but rather than having to check for the input being uppercase or lowercase, I'd rather convert it before checking it in an if statement.

I've created a function, and I know it works because when I print the output, it shows up capitalized, however when I check it with an if statement, it doesn't pass.

Here is my code:

#include <iostream>
using namespace std;
void stringUppercase(string x) {
int i;
for (i = 0; i < x.length(); i++) {

[Code] ....

View 4 Replies View Related

C :: Create Program That Takes In Information And Formats It Into 3 Columns - Float Variable Not Working

Dec 12, 2013

Here your supposed to create a program that takes in information and formats it into three columns.

I can't seem to use the float variable unitprice with decimal places here for, if I try to use %.1f and type in an input, the program seems to skip over the second scanf function, not allowing me to put input into the third scanf function as the program runs before I can.

I can use %f on its own and it works but this creates too many zeroes(and you're supposed to set the currency limit to $99999.99).

Code:
#include <stdio.h>
int main(void) {
int itemno, month, year, day;
float unitprice;

[Code]....

So the output should look like three columns. It's just the float that is the issue here....

View 5 Replies View Related

C++ :: Using A Library Function?

May 9, 2013

I have been trying to find a way around the following:

I am using a library functor to solve the root of a non linear equation. It passes two doubles and the name of a function that contains the equation to be solved.

Its xtor and operator are

RootFind(double tL,double tR,double (*fn)(double t));

void operator()(double tL,doubleR,double (*fn)(double t));

I want to be able to send another variable to function fn; I don't know what the value of the variable will be ahead of time.

How do I get the library functor to take an extra variable in the function passed?

View 1 Replies View Related

C :: Creating A Library Function

Jan 27, 2015

I want to create a C library function that i can directly call in my code from any .c file having main program.following are codes...code of library function "foo.c"

Code:

#include "foo.h"
int foo(int x) /* Function definition */ {
return x + 5;
} header file "foo.h"

Code:

#ifndef FOO_H_ /* Include guard */
#define FOO_H_
int foo(int x); /* An example function declaration */
}

[code]....

to use this i have to compile the file in below manner...

Code: gcc -o my_app main.c foo.c

My concern here is that i want to compile the main.c and use function without compiling foo.c with i.e.

Code: gcc -o my_app main.c

any user of this function should only compile his program and should be able to use the function, the foo.c file should remain hidden from him

my system is Linux 2.6.18-308.4.1.el5 #1 SMP Wed Mar 28 01:54:56 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux

View 9 Replies View Related

C++ :: Calling A Function Of A Library

Apr 6, 2012

I have a code like this below in /root_project/main.cpp:

Code:
#include "theoraplayer/TheoraVideoClip.h"
unsigned int tex_id;
TheoraVideoManager* mgr;
TheoraVideoClip* clip;
std::string window_name="glut_player";
bool started=1;

[Code] ....

and the TheoraVideoClip.h file is in /root_project/include/theoraplayer/.

Inside of TheoraVideoClip.h there is this:

Code: TheoraVideoFrame* getNextFrame();

And when I try to compile using g++ -o app main.cpp -lGL -lglut -lGLU -ltheora -ltheoradec -ltheoraenc I'm gettin this error:

main.cpp.text+0xac2): undefined reference to `TheoraVideoClip::getNextFrame()'

Ubuntu 11.10

View 2 Replies View Related

C/C++ :: How To Find Address Of Library Function

Nov 30, 2012

I want to find the address of printf() in c.

View 2 Replies View Related

C :: Converting Function Data To Array

Apr 4, 2013

How can I change this function so it stores each of the even integers into an array of integers?

Code:
void sumIntegers ()
{
int num = 0;
int i = 0;

[Code]....

View 1 Replies View Related

C :: Converting For Loop To Recursive Function

Jun 10, 2013

I am working on a problem that requires a nest for loop to be converted to a recursive function. I am going to provide just the code instead of the entire program.

Code:

for (R1=1; R1 <+3, R1++){ //for loop
printf (something);
}
// the recursive function
void loopR1 (int R1, int max){
if (R1 <= max){
printf (something);

[Code]...

when calling the recursive function in main i am using the following statement...

loop r1(1,3)

View 4 Replies View Related

C/C++ :: Converting Int To Double Pointer Outside Main Function

Dec 22, 2014

I have int pointer called p and i want to calculate average.Since average involves using double or float so i am trying to convert this in the function averagetemp. It still gives me an error saying "cannot be converted"...

#include <iostream>
using namespace std;
int* createArray(int n);
int lowesttemp(int *p,int f);
int highesttemp(int *p,int f);
double averagetemp(int *k,double f);
void print(int *p,int lowest_temp,int highesttemp,int average_temp);

[Code] ....

View 8 Replies View Related

C++ :: Operator Overloading In Library - Definition Of Dllimport Function Not Allowed

Aug 1, 2014

Code:
class VAR_EXPORT VAR {
public:
};
VAR_EXPORT QDataStream &operator>>(QDataStream &p_stream, QSharedPointer<Data>& p_data)

[Code] ....

Above compile and build ok. But when i build another library that use the above, i was shown with all errors complaining operator << and >> definition of dllimport function not allowed

error C2491: 'operator >>' : definition of dllimport function not allowed
error C2491: 'operator <<' : definition of dllimport function not allowed

View 1 Replies View Related

C :: Converting Two Strings To Upper And Lower Case Using Function

Dec 6, 2014

My code so far

Code:

#include <stdio.h>
#include <ctype.h>
#include <string.h>

[Code]....

I keep getting these 3 errors :

error expected '=', ',', ';', 'asm' or '__attribute__' before '{' token|.
error expected '=', ',', ';', 'asm' or '__attribute__' before '{' token|.
error expected '{' at end of input|.

View 4 Replies View Related

Visual C++ :: Creating Program To Make Sine Function Without Any Library Other Than Iostream?

Nov 10, 2012

My assignment is to create a C++ Program to find the sine of a number without any library other than iostream by using Taylor Series:

sin (x) = (x/1!) - (x^3/3!) + (x^5/5!) - (x^7/7!) + (x^9/9!) ...... (x^n/n!).

Here is what i have done till now:

#include <iostream>
double fact (int f); //declaration of factorial function
double power(double x, int y); //declaration of power function
double sin(int x); //declaration of sine function
//double cos(int x); //declaration of cosine function
//double tan(int x); //declaration of tangent function

[code]....

View 3 Replies View Related

C++ ::  typedef As Data Type For Specialized Template Function In Class From Shared Library

Jul 19, 2013

I have a class "Result" with a single template function Set(const std::string& arName, T& val) and a specialization of this function Set<Real>(const std::string& arName, Real& val) where Real is a typedef for double. The class is in a shared library and I use it in my main program. If I do result->Set<GLOBAL::Real>("U", 100.0); the wrong template function is called!

I check this by the output with std::cout.

Maybe it's a problem with the typedef.

If I link the object file of the Result class directly to my main program (no shared library), it works.

typedefs.hpp:
namespace GLOBAL {
typedef double Real;
} results.hpp
#include <iostream>

[Code] ....

View 3 Replies View Related

C++ :: Shared Library Vs Static Library?

Jan 17, 2014

I've been reading about libraries; How to make them, how to use them, the different types of libraries, etc..

When using a shared library, does the program require that library to be installed on the computer after the program has been compiled into an .exe?

Ie.. if somebody downloaded a "Helloworld.exe" that I had compiled on my computer using a shared library (that wasn't part of a standard operating system), would they also need that shared library on their computer for the program to run without errors?

and for Static Libraries, when I compile a program using a static library, does it include in the final binary only the functions of the library that are actually used, or does the compiler add in the entire library?

View 8 Replies View Related

C++ :: Calling Function By Sending Char Text Of Function Name

Feb 19, 2014

Is this possible?

int myfunc( int a, int b, char * c )
char a = "(int)myfunc()";
char b = "(int,int,char*)"
call(a, b, ...) // Function name and return type, params

I want to do function what registers forward what will get callback if the time is right. Basically then i dont need to edit and add extra functions into source files. I just have to include header and use register forward function. If there is anything close to this it would be perfect!

View 5 Replies View Related

C++ :: Find And Replace Function For Text Editor

Jan 3, 2013

I'm building a find and replace function for my text editor I'm building the function without support from the algorithm header.

The function is written like: doc.find_replace("Word_to_be_replaced", "The_word_that_is_replacing"); I find this very easy to understand replace this, with this.

find_replace will both have char * as their arguments.

The problem I'm having right now if I replace a bigger word for a smaller word how do I delete the extra characters from memory.

So if I replace "Goodbye" with "Hello" how do I delete the last two characters? So I don't print garbage code.

View 1 Replies View Related

C++ :: Function To Find Sum Of Certain Word In Text File?

Jul 26, 2014

I've written a function that has to receive a word as parameter, and then has to find the amount of times that word (uppercase & lowercase) occurs in a text file:

For example, if the word "the" is sent as a parameter, the total amount of times the words "the" and "THE" occurs in the text file, has to be calculated.

However, my function is not displaying the correct amount, what is wrong with my function:

int WordCount :: countWords(string wrd)
{
int counter=0;
string temp = "";

[Code].....

View 1 Replies View Related

C++ :: How To Output Void Function On A Text File

Feb 12, 2013

So I am writing this code that analyzes a file called "analysis.txt" and prints out in an ouput file (called "report.txt") the results of the analysis, i.e.,(the frequency of all alphabet letters present in the file).

I am having trouble with outputing on the file2.

here is what I have:

Code:

#include<iostream>
#include<fstream>
using namespace std;
ifstream file1;

[Code]....

I tried to lose the "<<" after the file 2, but it's still giving me an error. how to output a void function on a text file?

View 14 Replies View Related

C++ :: Use Find Function To Search For A Line In Text File

Oct 28, 2013

I'm trying to make a program that will search for a line in a text file using a non default delimitor at the start of the line. An example line in the text file would be as follows:

F Mary Smyth, 19, United Kingdom

I have been able to use the find function to search for and return the 'F' character but would like it to then display the whole corresponding line. Is this possible with the find function?

ifstream readFromFile("data.txt");
string Destinations[1] = {"F "};
string data;
while(!readFromFile.eof()){
getline(readFromFile,data);

[code]...

View 2 Replies View Related







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