Well I tried to assign a new char value from a struct to another char variable but I got the "Cannot convert 'int' to 'char'" error when compiling. I've tried several alternations but I still can't get away with this error.
Here's a section of the code:
javascript:tx('code') for(int i = 0 ; i < 10 ; i++){ pts[i].dist = sqrt((pts[i].x*pts[i].x)+(pts[i].y*pts[i].y)); }
I have a problem with rotating an array and assigning it to different variables. This is wat i have done.
Code:
#include<stdio.h>#include<stdlib.h> #include<conio.h> #include<math.h> int n[16],a[16],n1[16],n2[16],n3[16],n4[16],n5[16],n6[16],n7[16],n8[16],n9[16],n10[16],n11[16],n12[16],n13[16],n14[16],n15[16],n16[16], c=0; int x[16],i,j,k; int rotate();
My homework wants me to take an input that is "x1888.88" and assign the "x" to a char, the "1" to a char, and the "888.88" to a float. How i can do this? and the "888.88" part could be any length could be a single digit or multiple with a decimal.
Is it possible with a struct? How to express this to search engines so I haven't been able to find anything about it. If this is not possible with a struct, is there a way to define something that can do all the following things:
SomeStruct test = {0.5, 0.5, 0.5, 1}; test.g = 1.0; test[0] = 0.0; // test[0] would be equivalent to calling test.r float somevalue = test[3]; // test[3] would be equivalent to calling test.a
I was attempting something weired with address to move data around when I discovered that the size of the array is not what I expected. I am passing this structure as &Users to a function that declares it as a void *, then I can deal with chunks of data (memmove) and not have to worry about index or things like that. However...sizeof is returning something I do not understand.
Im having trouble creating a struct within a struct node. the program suppose to hold students firstname, lastname, and gpa in a node therefore creating my linked list. Line 26 keeps saying that cannot convert parameter 2 from 'studentType to std::string
error: request for member 'character' in '* ptr', which is of non-class type 'datastructure*' error: request for member 'character' in '* ptr', which is of non-class type 'datastructure*'
These errors are related to " *ptr->character='a'; printf("Ptr: %c",*ptr->character); "
I want to access "character" data inside the structure "trial" by a pointer to pointer "ptr" inside function "function",but I couldn't find a way to do this.
I am having a problem assigning bits a value of 0. The data is a 16 bit integer the bits greater than the 12th bit have garbage either a 0 or a 1. I would like to assign all bits greater than 12th bit the value 0 no matter what their values are. Whats the best approach.
I thought we needed to allocate memory before assigning a value to a char* and also that we needed to use functions like strcpy() to copy something into it. Then how come this works and does not crash?
I've seen code examples for assigning 2 dimensional vectors, but I haven't seen code for assigning more than that. I tried to create a 3 dimensional vector, and the only code the IDE didn't complain about was
int x = 2; int y = 2; int z = 2; vector < vector < vector <string> > >stringvec; stringvec.assign(x, vector <string>(y), vector <string>(z));
Would this be the correct way of producting a vector[2][2][2]?
In the current code,We are using pointer of union and assigning value.
class sample { union { short *two_int; int *four_int; double *eight_real; char *one_ascii; // void *v; }; }
Than we assign value in following way.
sample.four_int[0] = (x + xoff); ( x and xoff and y and yoff all are integer) sample.four_int[1] = (y + yoff);
Than we write data into file. it was working fine into 32 bit machine but it is not working 64bit machine. When I compare data and found that data is divided by 4. For Ex The File generating from 32 bit machine contain 80 than 64 bit . File contain 20.
I have created a string array of 5 and I will use that to enter some "tasks", then I also have an integer array of 5 where i can assign priorities to the information in the string
string info[5]; int p[5]; cout<<"Enter info 1"<<endl; cin>>info[0]; cout<<"Enter priority"<<endl; cin>>p[0];
etc,
I want to be able to link the priorities that i assign to that string and be able to call the information that has the highest priority. I can only using iostream and string header files so far,
I want to assign a char to an array inside an if statement after the user has input the grade as an integer, but it has to fill an array with characters, such as:
char grades[5]; int grade; char A, B, C, D, F; cout << "Enter da grade" << endl; cin >> grade; if (grade < 59) { grade[0] = F;
[code]....
A, B, C, D, and F won't transfer to the array, thus giving me the uninitialized variable error in microsoft visual studio 2010.
typedef union UUID { unsigned char byte[16]; /**< Array of 16 bytes. */ unsigned int ll[2]; /**< Array of two 64-bit words. */ } UUID;
[Code] ......
The compiler complains thus
$ g++ union.cpp union.cpp: In function "int main()": union.cpp:15:17: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x union.cpp:15:17: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x union.cpp:15:17: error: no match for "operator=" in "entry.EntryHeader::uuid = {0, 0, 0, 2}" union.cpp:1:20: note: candidate is: UUID& UUID:perator=(const UUID&)
How do I go about assigning values to this union in C++.
I need to dynamically build a control file for a SQL loader but when tokenizing line values read from a file i am unable to work/assign the last value to a variable even though i can print the actual token value while in the loop.
Below is the code snippet i have and get:
Code: //headElement declared as headElement[42] //getCol function is used to decode column keys present in line being read istringstream ss(line);
How to scan a CSV file and assigned variable to each of the integer scanned in a csv file
an example of the csv file: 0001,40,,10
How do I scan the CSV file and assign 0001 to variable student id, the 40 to variable module 01,the 1 without input entered to module02 and 10 to module03
I'm making a game that requires the user to enter a correct username and password to play. I have a list of accepted ones saved in a txt file. How do i read each line of the file and check it with the one entered? I know how to use strcmp(string1, string2). I just need to know how to move from one line to the next. This is what I have for this part of the program so far. Also, I think im using the feof() wrong.
In another forum, this example code fragment was stated as being an example of undefined behavior. My understanding is that a literal string exists from program start to program termination, so I don't see the issue, even though the literal string is probably in a different part of memory.
Code: /* ... */ const char *pstr = "example"; /* or even */ char *pstr = "example"; /* as long as no attempt is made to modify the data pointed to by pstr, */ /* unless pstr is later changed to point to a stack or heap based string */
What I am doing is using fgetc to take a char input from the user, and then directly after that calling a function which will clear the buffer and remove the character. But for some odd reason all my inputs are being assigned before taking the char input by the user. Here is my code for the relative problem:
Code: char playAgain; Code: playAgain = fgetc(stdin); readRestOfLine(); Code: void readRestOfLine(void) { int ch; /* remove all characters from the buffer */ while(ch = getc(stdin), ch!=' ' && ch!=EOF) ; /* clear the error status of the input pointer */ clearerr(stdin); }
And en example through terminal of the issue, with print statements debugging the value of play Again:
So in both instances here I have entered 'y', one returning it as ASCII 10 which is ' ' and ASCII 121 which is 'y'.
I'm trying to write a very simple program that takes values in through variables, and stores those values in a two dimensional array. The values are already passed into the void function, I need to have those values write to their corresponding locations in the array.
void planeSeats(int seats[13][6], int ticket, int ticketRow, int ticketColumn) { if (ticket = 1) { if (ticketRow >= 1 && ticketRow <= 2) {
[Code] ....
For example, lets say that ticketrow is 2 and ticket Column is 4 .
What I need is for ticketRow and ticketColumn to assign that data to seat[ticketRow][ticketColumn], turning it into seat[2][4]. How to do that.