C :: Convert From Array To List And Back
Nov 26, 2013
I need to convert from an array to a list and back.
array to list: (x,y) to int and int to (x,y)
I wrote this function:
Code:
/*
* inputs:
* coordX: column;
* coordY: line;
* nc: number of colums
[Code] ....
It works fine but the other way around is giving me sleeping problems. I was thinking something about this:
Code:
/*
* inputs: integer
* returns: X coordinate
*/
int inttoX(int n, int nc){
int coordX;
[Code] .....
I don't need the code, just want to continue... i'm a little blocked.
View 2 Replies
ADVERTISEMENT
Sep 5, 2013
I receive a byte stream. The first 8 bytes contain an Identification number. I receive at first the lowest byte and at the end the highest byte of the number. How can I transform this into a double value and later back into the bytestream? In the past I hard only 2 Byte values and there I could use things like MAKEWORD and HIBYTE and LOWBYTE to convert the values
View 4 Replies
View Related
Aug 21, 2014
I would like to write a complete structure array to a file and read it back, recovering all the data. I have tried the following:
Code:
#include <stdio.h>
#include <string.h>
#define NUM 256
const char *fname="binary.bin";
typedef struct foo_s {
int intA;
int intB;
char string[20];
[Code]...
//---------------------------------------------------- but the mac field is reading back some random value repeatedly. Why is that? And how do I fix this?
View 8 Replies
View Related
May 27, 2012
I have a txt file of drinks, and I want to meak a list of buttons of it (the txt file is build like this: fanta : 2 ), how can I make buttons of all the drinks ( I get the first one in a button , but not the others).
Dictionary<string, double> drank = new Dictionary<string, double>();
string[] words = new string[8];
Button button;
<Button> BtnList = new List<Button>();
[Code] ....
View 1 Replies
View Related
Sep 26, 2014
So I query out data from multiple tables and I put it as anonymous type. But since I need to get the remove function going, my datagridview has to get datasource from a bindinglist, not just a list. What could I do from this situation? I already checked: [URL] but intellisense doesn't pick up the .ToBindingList() function for my query.
View 3 Replies
View Related
Dec 10, 2014
Okay, so I'm getting an error I've never seen before.. I'm trying to convert a List<string> to a DataTable. Not a List<string[]>, but a regular ol' List<string>. I figured this code would do the trick, but to no avail:
public static DataTable ToDataTable<T>(List<T> items) {
DataTable dataTable = new DataTable(typeof(T).Name);
//Get all the properties
PropertyInfo[] Props = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);
foreach (PropertyInfo prop in Props)
[Code] ....
I keep getting an error on "values[i] = Props[i].GetValue(item, null);", that reads:
"An unhandled exception of type 'System.Reflection.TargetParameterCountException' occurred in mscorlib.dll
Additional information: Parameter count mismatch."
I don't know what it means by Parameter count mismatch...
View 3 Replies
View Related
Mar 16, 2013
I am need to compare 2 items from 2 separate drop down lists. These values are of int type. Say for example 2 drop down lists showing years. Now i need to find out these 2 years selected is greater or nearer to the current year.
I tried converting the values i receive from the drop down lists to int variables. But i am getting error then. I gave it like below.
int tmp = Convert.ToInt32(ddl_1.SelectedItem.Text);
this gives an error like this - Input string was not in correct format.
I need to know how to put an item from a drop down list to a variable of int data type.
View 1 Replies
View Related
Feb 11, 2013
I have a problem set where i have to read in numbers from a file as strings, convert from strings to integers, and pass the integers into a linked list, where each integer is a node. This is what I have so far:
Code:
# include <stdio.h>
# include <stdlib.h>
# define MAX_INT_SIZE 10000
typedef struct integer BigInt;
struct integer {
[Code] ......
View 10 Replies
View Related
Sep 23, 2014
I am trying to make a program that will convert a list of binary numbers from a file into decimal and print the decimal to the screen. I have no problem doing the conversion, the problem comes up when our teacher wants the input file in a format as such:
3
10110101
11111111
10101010
The first number is supposed to tell the program how many different 8bit strings it is going to have to convert, and then the following lines are those binary numbers.
I am not very experienced with file inputs, and I know how to open files and read lines in.. The problem is, how to say "ok the first line says 3, so now I have to convert the next 3 lines" . I am assuming it is just a simple loop that I am missing....
View 4 Replies
View Related
Feb 9, 2015
How to output vector contents using the push_back function. My program reads in values just fine, but it does not output anything and I've been stuck on why.
here is my code:
#include <iostream>
#include <array>
#include <vector>
using namespace std;
int duplicate( vector < int > &vector1, const int value, const int counter)
[Code].....
View 3 Replies
View Related
May 8, 2014
I'm having trouble converting this binary search with an int array to use a string array..
Code:
#include <iostream>
#include <string>
using namespace std;
// Function prototype
int binarySearch(string [], int);
[Code] .....
View 3 Replies
View Related
Mar 2, 2012
I have the following code which attempts to assign a u_int8 array of 256 to an unsigned char[256]:
Code:
unsigned char testData[256]=pSample->data;
I get the compilation error:
error C2440: 'initializing' : cannot convert from 'const uint8_t [256]' to 'unsigned char [256]'
What is the safe way to cast or convert here?
View 3 Replies
View Related
Jan 19, 2014
I have almost a hundred names in a text file that I want to convert to email addresses and save to another file. I seem to have it working, but it doesn't print the full names in the email prefix. The output I'm looking for is Doe_John@livebrandm, but I'm only getting D_J@livebrandm. I'm not sure what I should specifically be reading up on that applies to this directly.
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE *fpin=fopen("namesIN.txt", "r");
FILE *fpout=fopen("emailOUT.txt", "a");
char first[20],last[20],inbuff[1500];
[Code]...
View 9 Replies
View Related
Jan 24, 2013
I am writing code to multiply two int arrays and in my one function i am trying to convert the char array into an int array. I have tested many parts however i can not find the problem.
Code:
struct integer* convert_integer(char* stringInt){
struct integer *converted = malloc(sizeof(struct integer));
int length, i, *ints;
ints = (int *)malloc(10001 * sizeof(int));
length = strlen(stringInt);
printf("stringInt: %s with length of %d
", stringInt, length);
converted->size = length;
[Code]...
View 5 Replies
View Related
Nov 23, 2013
Is there anyway we can make an integer array to an integer...
View 4 Replies
View Related
Feb 21, 2013
I have an array:
Code: int array1[]={0,1,1,0}
I need to convert the entire array to Hexadecimal.
My first thoughts to the approach was to convert the array to a string then strcmp but i cant seem to find how to convert an array to a string either.
How to convert the array to hexadecimal directly? or, How to convert the array to a string to be strcmp'ed?
View 6 Replies
View Related
Nov 5, 2013
I'm trying to convert int x and y arrays to string using a sample code found online.
string Square::int2string (int x[]) {
string returnstring = "";
for (int i=0; i < 4; i++) {
returnstring += itoa(x[i]);
return returnstring;
}
}
but hit with the following error.
Square.cpp:30:8: error: prototype for ‘std::string Square::int2string(int*)’ does not match any in class ‘Square’ Square.h:21:10: error: candidate is: std::string Square::int2string()
I declared the following in header file.
string int2string();
The error is due to variable type does not match. Is there a better way to convert int array to string?
What I'm trying to achieve is a string printed in the following manner:
Point[0] (x1,y1)
Point[1] (x2,y2) and so on.
View 5 Replies
View Related
Feb 23, 2013
how to covert float value to array get any sessegation to convert the value
View 1 Replies
View Related
Jun 7, 2012
I want to convert int to char array for get the total of digits like this..
Code:
int total;
char charnum[2] = (char)total; //this is the problem
int num = 0;
for (int i = 0; i <2; i++)
{ num += charNum[i] -48;}
cout << num;
If total was 42 i want to get output as 6. for this purpose i want to convert int to char.
View 7 Replies
View Related
Oct 15, 2013
Currently I have:
Code:
char my_array[4] = { '1', '2', '3', '4' };
how do I convert the above to a string of: "1234"
View 6 Replies
View Related
Mar 8, 2013
.I have this string that I need to convert into a 2d char array like this:
String str= "A,E,B,I,M,Y#N,R,C,A,T,S";
I know how to use delimiter and split string and I know how to convert but only from string to char[].I need something like this:
Input: String str= "A,E,B,I,M,Y#N,R,C,A,T,S";
Output: [A] [E] [B] [I] [M] [Y][N] [R] [C] [A] [T] [S]
View 6 Replies
View Related
Feb 21, 2013
Without lossing information?
View 14 Replies
View Related
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
Mar 6, 2015
How to convert char array into double?,i.e. store char array values into a single double variable. Below is the code that i'm working. Im extracting the value "2255.1682" from char array gpsdata1. I used while loop, extracted the value and stored in "myChar", but i want to store it in double variable "lat1".
Code:
#include <stdio.h>
#include <stdlib.h>
int main(){
unsigned char gpsdata1[]="$GPGGA,091310.000,2255.1682,N,11356.3605,E,1,4,1.62,164";
char myChar;
double lat1;
[Code] .....
View 5 Replies
View Related
Nov 9, 2014
Platform : c++, compiler: GNU gcc
I am new to programming and have written the code for the following program.
PROGRAM: Input 2 arrays => arrays 1 and 2 from the user each containing 5 elements. Sum is another array which is sum of elements of array 1 and array 2. Convert each of the elements of the sum array into binary. Count number of 1's in each binary element and output it to another array "arr".
Example: arr1 = {1,2,3,4,5}
arr2 = {6,7,8,9,10}
sum = {7,9,11,13,15}
binary of 7 [111], 9[1001], 11[1011], 13[1101], 15[1111]
No of 1's in 7 [3], 9 [2], 11 [3], 13 [3], 15 [4]
arr array will be {3, 2, 3, 3, 4}
I am not getting the desired output. My code is:-
include <iostream>
using namespace std;
int main() {
int array1[5];
[code].....
View 2 Replies
View Related
Jan 27, 2015
i want to convert in loop for example this
char number[]="54465465445646848640";
and in loop convert these element to int one by one.
View 1 Replies
View Related