C++ :: Strings And Constant Chars - Stream A Constantly Changing Float Into Coord

Apr 16, 2013

So, I'm working with cocos2d-x and there's a specific function used to print true type fonts to the screen. My problem is that I want to feed a string into the function, but it only takes a string of const char (Which I don't even know what that is. AFAIK strings are a string of chars, not const chars).

Here's a definition of the function :

CCLabelTTF::create(const char *string, const char *fontname, float *fontsize);

an example of it being used

CCLabelTTF *pCoord = CCLabelTTF::create("Coordinates", "Arial", 42.0);

What I want to use

std::string coord;
//stream a constantly changing float into coord ...
CCLabelTTF *pCoord = CCLabelTTF::create(coord, "Arial", 42.0);

What happens : Error : no instance of overloaded function "...CCLabelTTF::create" matches the argument list. Argument types are (std::string, const char [6], int)

Basically, What I need to know is how would I feed a constantly updating string into the 1st argument?

View 3 Replies


ADVERTISEMENT

C++ :: Convert Chars To UTF-8 Hex Strings

Sep 27, 2013

I am trying to convert some chars to UTF-8 strings...

Example:

std::string gethex(char c) {
/* EXAMPLE
if (c == 'é')
return "%c3%a9";
I need a function that converts chars like "á, é, í, ã" to UTF-8 hexadecimal strings...
*/
}

[Code] .....

[URL] .... does it. Choose UTF-8, type some character and click 'Url Encode'.

View 14 Replies View Related

C :: How To Convert From Array Of Chars To Strings

Jan 13, 2014

As a part of a program I am supposed to write, I would like to receive a string from the user (for example: "Hi my name is Joe").

obviously, the string is inserted to an array of chars (arr[0]='H', arr[1]='i', arr[2]=' ',... and so on).

What I would like to do, is to put each word separately in each array cell (for example arr[0]='Hi', arr[1]="my"..., and so on). How can I do this? (I can not use any functions, unless I write them myself).

View 8 Replies View Related

C++ :: Debug Error When Taking A String And Casting It To Float With File Stream

May 9, 2014

Debug Error

ProjectsFinal ProjectGrItemDebugGrItem.exe

R6010 - abort() has been called

I was going over this with a friend and it seems as though getline() is not reading anything in and thus throwing the abort error. I'm not sure why this is because I've included the textfile, with the correct name of course, in both the regular file location and the debug folder. I ask for user input and the user then inputs the name of the file they want, I do some required things behind the scenes and display the results for them in a cmd window. I've included pastebin files for both my header and cpp files because it is far to large for one post I shall, however, post the full code in the comments.

Quick Code

The problem occurs on line 159. I'm assuming once this line is fixed, line 163 will have the same problem.

// Read regular price
getline(nameFile, input, '$');
vectorList[count].regPrice = stof(input.c_str());// Casts string to a float
// Read sale price
getline(nameFile, input, '#');
vectorList[count].salePrice = stof(input.c_str());

Pastebin Links : [URL] ....

View 2 Replies View Related

C++ :: Why Are All Strings Constant

Apr 10, 2013

why all strings are always constant?

View 2 Replies View Related

C/C++ :: Merge-Sort With X And Y Coord From File

Apr 17, 2014

So I have a file with 2 float numbers like this

0.041631 0.176643
0.364602 0.091331
0.092298 0.487217
0.526750 0.454433
0.233178 0.831292
0.931731 0.568060
0.556094 0.050832
0.767051 0.018915
0.252360 0.298197
0.875981 0.531557

I would like to place the first column in one array and second in another. I am using the merge sort and merge algorithm from my book to sort the first column (x-coord) in descending order and the second column (y-coord) in ascending order. The output would look like this.

(where, x, y)
6: 0.931731 0.018915
10: 0.875981 0.050832
8: 0.767051 0.091331
7: 0.556094 0.176643
4: 0.526750 0.298197
2: 0.364602 0.454433
9: 0.252360 0.487217
5: 0.233178 0.531557
3: 0.092298 0.568060
1: 0.041631 0.831292

I am ignoring the where(line number) for now. The error I get is: cannot convert 'points_struct*' to 'int*' for argument '1' to 'int mergesort(int*, int, int)'.

So my question is how to get my points_struct arrays to work with the algorithm I have from book. Here is what I have so far.


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

[Code].....

View 4 Replies View Related

Visual C++ :: File Stream Change Its Address During Writing Text Contents To The Stream

Apr 29, 2013

I wrote a program to write text contents to file stream through fputs, the file stream address was changed in the middle of writing text content to the stream (11% text content have been put into the file stream), that cause the file stream pointer can be evaluated problem and raise exception on stream validation code in fputs library function, my question is what things could go wrong to make file stream pointer changed its address to something else or a NULL pointer if the file stream have not been flushed and closed.

View 5 Replies View Related

C++ ::  SDL2 / Player Not Moving Constantly

Feb 16, 2015

Im using SDL2 but I'm encountering an unexpected error. I have implemented the same method to move as in my old Projects, but the Player appears to be stuck...

The Player is stuck for maybe half a second, and then everything works as it should, but every time I Change direction or i start moving the Player is stuck for a short Moment.

#ifndef _PLAYER_HPP_
#define _PLAYER_HPP_
#include <iostream>
#include <string>
#include "SDLGameObject.hpp"
class CPlayer : public CSDLGameObject

[code]....

View 9 Replies View Related

C Sharp :: How To Stop GUI Lag When Working Constantly

Oct 23, 2012

When my program is working with a big list, it always connects to the internet and checks information from a website. It is going fast, but when I'm trying to update a label on every connection, it just shows at the end, when everything is checked. Progressbar value is updating. How to solve this?

View 1 Replies View Related

C :: Distinguish Between Character Constant And String Constant

Feb 20, 2015

Can distinguish between character constant and string constant giving examples

View 1 Replies View Related

Visual C++ :: Constantly Calling Ostrstream - Private Member Access Violation

Sep 22, 2014

Code:
std::ostrstream oss;
oss << "path for " << unit << "
" << path;
puts(oss.str());

[Code] .....

Today, I just received this new fresh error, I was constantly using them, but just come to know it is a private access violation as the last error of my program. Did I use it in the wrong way?

View 3 Replies View Related

C++ :: Turning A Limited Float Into Another Float?

Nov 20, 2013

I can do the folowing:

float var1 ;
var1 = 9.12345 ;
printf("%.2f",var1) ;

the output will be 9.12. What if I wanted to save that as another separate float with displaying it on screen?

View 1 Replies View Related

C/C++ :: Cannot Convert Float To Float Assignment

Jun 8, 2014

#include <iostream>
#include <string.h>
#include <sstream>

[Code]....

View 1 Replies View Related

C++ :: Non Constant Member Function Being Called Inside Constant Member Function?

Dec 28, 2012

#include <iostream>
class Hello {
public:
void Test() {

[Code].....

As i know a non-constant member function cant be called inside a constant member function but how the above code has been compiled successfully and giving the expected result .

View 5 Replies View Related

C++ :: Looking For Chars In String

May 20, 2013

I'm looking for a algorithm to search portions of string that have the same caracter. The only possible values are: a,n and g

Char index: 0 1 2 3 4 5 6 7 8 9 RESULT
------------------------------------------
Example 1: a g g g a a 0,4
Example 2: g g g a n n a 0,3
Example 3: a g g g g g g a 0,7
Example 4: g g g g g g g 0,6
Example 5: g g a a g a a a g 0,2,3,5,7,8

View 4 Replies View Related

C :: Swap Chars Using Getchar

Sep 23, 2014

This is for homework . Must use only getchar and putchar

Code:

int main(void) {
int pch; //first
int ch; //second

[Code]....

And it works , but i need to hit ENTER two times when i have 3,5,7... chars to print result.

View 6 Replies View Related

C :: Reading In A File Of Chars Until EOF

Apr 13, 2013

I'm working on a homework project, and it requires me to read in a file of chars into an array, and then do stuff with that array.

Anyways, I have the first part written, where I'm just trying to read in my data.txt file, and I thought I had it written well. It compiles, but then it seg faults, and I'm not sure why. I used calloc for the array, but maybe I misused it? Or is it in my EOF statement? I'm still not sure if that's coded correctly. I need to get past this so I can start testing the other parts of my code.

Code:
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char* argv[] ) {
/* Local Declarations*/
int i;
int *ptr;
char tempc;

[Code] .....

View 1 Replies View Related

C++ :: Comparing Chars In A While Statement

Jul 1, 2014

I am trying to do this but it can never seem to work.

#include <iostream>
using namespace std;
int main () {
char charOne;
cin.get(charOne);
cin.ignore(1000, '

[Code] .....

Basically i want to keep looping until i enter an a or A (also does this apply to if statements as well?)

View 6 Replies View Related

C/C++ :: Put Special Chars In A Message

Apr 10, 2014

I'm trying to put in my messages, in my program, some special chars but when i try something like the following code, i get the output below.

#include <stdio.h>
int main( ) {
printf("Trying this char: %c", 160);
printf("Trying this char: %c", 163);
return 0;
}

Output:
Trying this char: �
Trying this char: �

How can i put those special chars? I would like to use: é, ú, ç, à, Ú, À, ...

View 14 Replies View Related

C/C++ :: Printing Out Unicode Hex As Chars

Feb 10, 2014

I'm writing a school assignment that writes/reads user input into and out of a binary file.

I've gotten the write part to work, but now I need to be able to read that file back in and display it as a string.

I think I should be using fread() and read my file into an array of int's right? But when I try printing out that array I get a whole bunch of numbers that don't match the hex code in my file.

How do I read in a binary file and print it out as a string?

View 4 Replies View Related

C# :: Reverse Chars Of String

Aug 7, 2014

I have a problem with my code. I just have to reverse the chars of a string, but it adds a /n that I can't delete.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ch05Ex05._5 {

[Code] ....

View 5 Replies View Related

C++ :: Print Chars As Keys Are Hit?

Mar 31, 2012

I found this method

Code:
TCHAR win_getch()

(below) on a website which is used for printing the characters as the keys on keyboard are hit i-e without hitting the ENTER key. This method is used in a while loop like this

Code:
while ((c = win_getch()) != 13)
{}

I wanted to know why is the character compared to

Code:
13
i-e
Code:
if((c = win_getch()) != 13) then do something

Code:
/**
* This function will simulate the getch() function from conio.h.
* Note that this does not work for special keys like F1-F12, arrow keys,
* even the ESC key does not seem to work with this function.
* @return TCHAR read from input buffer.
*/
TCHAR win_getch() {
DWORD mode;
TCHAR theChar = 0;

[code]....

View 2 Replies View Related

C :: Converting Random Numbers Into Chars?

Apr 3, 2013

I am having difficulty completing 7th last line below I marked the line with an arrow.

Code:
int main(void) {
int MaxNum, /*number of random nos to generate */
i, /*index */
value,

[Code].....

View 4 Replies View Related

C :: Adding Chars From File To Array

Jan 29, 2014

lets say we have a txt that contains this

| | | | |*| |
| | | |*| | |

and that symbolizes a 2x6 char array and we want to take only the symbols inside the || and place them in a 2x6 char array. how do we do that?

View 1 Replies View Related

C++ :: Remove Non-Displayable ASCII Chars

Jan 7, 2014

How to give input with text for this function.i already create function for this but i dn't know give input as non ASCII value(0-32) that Cobain with string or simple text.

View 1 Replies View Related

C++ :: If Multiple Same Chars Found Then Drop One

Nov 20, 2013

For some reason my code is not couting right. My function is supposed to decipher some code that if it has multiple same chars then it drops one. Example aabbyfkk --------> abyfk. But it couts abyffkk . For some reason it is not getting rid of the extra f and k chars.

string decrypt (string encrypted) {
string deleted, tmp;
int i, pos, n, j=0, z;
tmp=encrypted;

[Code] ....

View 3 Replies View Related







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