Visual C++ :: Storing 2D Char Array?

Nov 20, 2012

I am unable to understand why is the output for this shows me the address of the stored array.

int main()
{
size_t k= 0 ;
char t[3][100] = { "hi", "di", "fi" } ;
char s[3][100] ;

[Code]....

View 5 Replies


ADVERTISEMENT

C :: Assign Integer Value To Unsigned Char Array But It Is Not Storing Integer Values

Oct 25, 2013

I am trying to assign the integer value to unsigned char array. But it is not storing the integer values. It prints the ascii values. Here the code snippet

Code: uchar uc[100];
for(i=0;i<100;i++)
{
uc[i] = i;
}

The values which are stored in uc[] is ascii values.I need the integer values to be stored in uc[]. I tried to do it with sprintf. but the output is not as expected. if I print the uc[i] it should diplay the value as 0,1,2....99.

View 9 Replies View Related

C/C++ :: Sending Char And Storing It In Vector

Feb 3, 2014

I've got something I'm trying to accomplish, but crashes my program.

I've got my server and client code.

Having the client send a message they type (char Chat[1024]) And the server receiving the chat (char recv_chat[1024]) only to send it to all connected clients again. Which the server sends the recv_chat.

The client receives it (char recv_chat[1024]). This works, and the client gets the right info. However, I'm trying to store it using a vector. I'm sure I've tried any way possible.

Client storing vector pseudo-code:

vector<char*> SaveChat;
int main () {
while (true) {
if (newClientConnected) {

[Code]....

This doesn't work, and crashes my application. I've tried changing the vector to string, const char*, basically anything I can with no avail.

View 8 Replies View Related

C++ :: Storing Numbers Into 2D Array - Invalid Types Int For Array Subscript

May 17, 2014

#include <iostream>
#include<fstream>
int decryption(int);
int multiply(int,int[][2]);
using namespace std;
main(){
int n;
ifstream inFile;
inFile.open ("out.txt");

[Code] .....

I was trying to store numbers read from a text file into 2D array but I am getting the error above.here is where the error occurs:

line 33: cout<<m[i][j]<<" ";

View 4 Replies View Related

Visual C++ :: Storing Some Variables In Disk?

Feb 9, 2014

I am using Visual C++ to write an app. One problem is that the application will allocate a lot of object instances of a specific class CMyObject, maybe 400, 000. This will cause "Out of memory" error when total allocated CMyObject reaches 400,000.

To solve this problem, I just wonder when a new CMyObject instance is created, is it possible to specify so that the instance will allocate on a disk cache, or file mapping instead of the memory space?

View 3 Replies View Related

Visual C++ :: Reading And Storing TXT File

Feb 12, 2014

I am trying to read and store a txt file with format below:

2.5;abc;2,4000
2.5;bef;3,2000
2.5;ref;3,1000

I try the fscanf( pFile, "%d;%s;%d,%d", buffer,buffer2,buffer3,buffer4 ); to store 2.5 to buffer, abc to buffer2, 2 to buffer 3 and 4000 to buffer 4 on first line.

However, it doesn't work. How can I achieve this? I want to read the 2nd line and so on.

Code:
char buffer[100]="";
char buffer2[100]="";
char buffer3[100]="";
char buffer4[100]="";
FILE * pFile=NULL;
pFile = fopen("C: est est.txt", "r");

[Code] ....

View 11 Replies View Related

C++ :: Comparing Char Array To Char Always Returns True

Dec 23, 2014

I've made a code to check whether or not a save file has been created correctly, but for some reason it always returns this line: readdata[qa]=='1' as true. in which qa is the counter I use in a for loop and readdata is a character array consisting of 50 characters that are either 0, 1 or 2.

this is the entire code:

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

[Code]....

at first is also went wrong at line 22 and also returned that as true, but then I added brackets and it worked.

View 4 Replies View Related

C++ :: Concatenate Two Char Arrays Into Single Char Array?

Sep 29, 2014

I am trying to concatenate two words from a file together. ex: "joe" "bob" into "joe bob". I have provided my function(s) below. I am somehow obtaining the terminal readout below. I have initialized my memory (I have to use dynamic, dont suggest fixing that). I have set up my char arrays (I HAVE TO USE CHAR ARRAYS (c-style string) DONT SUGGEST STRINGS) I know this is a weird way to do this, but it is academic. I am currently stuck. My file will read in to my tempfName and templName and will concatenate correctly into my tempName, but I am unable to correctly get into my (*playerPtr).name.

/* this is my terminal readout
joe bob
<- nothing is put into (*playerPtr).name, why not?
joe bob joe bob
seg fault*/
/****************************************************************/
//This is here to show my struct/playerInit

[Code]....

View 2 Replies View Related

Visual C++ :: Class For Storing Values Inside XML File

Oct 9, 2014

In VC++ is there any inbuilt class for storying values inside an XML File, without using CLI?

View 14 Replies View Related

C++ ::  Storing Entire One Array Into One Cell Of Another Array

Jul 31, 2013

Take for example two arrays.

int A[2][2][2] = { {{1, 2}, {3, 4}},{{ 5, 6}, {7, 8}} };
int B[1]

I want to store the entire array "A" into B[1]. Is it possible?

View 2 Replies View Related

C :: Char Array With A Phrase To Char Word

Nov 28, 2013

I need to do a function that copy every word from a text to a char word. How can i do it?

View 5 Replies View Related

C :: Storing Strings Into Array

Mar 27, 2013

I am having trouble storing strings into an array. Basically I have a console program where it has an option. This is just an example;

Code:
char name[max];
char listofnames[maxname];
int counter;
....
printf("Add names
");

And how can I print it?

View 9 Replies View Related

C :: Storing Array Of Structures

May 4, 2013

So i have a program with the structure

Code:

char record[20];
typedef struct{
int id;
char title[20];
char subject[20];
char faculty [20];
int level;
char fname[25];
}report;
int recno,i;
report list[100];

I need to store the hundred records into a file. What are the functions and elements i should use/introduce.

View 2 Replies View Related

C++ :: Storing Class In Array

May 2, 2013

How do I go about storing info to an array of class?I need to do something like this:

info[count] = ReadNameRating(n, r);

Where info is an array of my own class and ReadNameRating reads the name and rating which is two of the variables handled by that class.

View 2 Replies View Related

C++ :: Storing Classes In Array

Sep 27, 2013

I have a base class Building. Then come its children classes - Commercial Building and Residential Building. The third level is composed of Apartment and House classes, both inherit from Residential Building.

I need to create an array of 20 elements that will store info about all these different types of buildings(Commercial Building,Residential Building,Apartment, House). How should I proceed?

View 5 Replies View Related

C++ :: Storing Filenames In Array

Oct 2, 2012

I want to create filenames such as Query.student.1.bin and save them in an array. I have no problem when I don't include a "." between student and number "1" but as I add a "." there my code does not run. ( it does complie but crashes during the run)

string *filename_str;
filename_str =new string[Number_X_Axis];
for(i=0;i<Number_X_Axis;i++)
filename_str[i]="Query."+Table_Name+"."+convertInt(i)+".bin";

View 2 Replies View Related

C :: Storing Integers To Character Array?

Jan 30, 2013

I am creating a program and am having trouble with one part. The input file looks like:

Code:
2
3
Bill Jeff Steve
Linda Brittany Jessica
3 1 4
2 1 9
8 3 7
6 4 9
4 8 9
6 9 4

Where I am stuck is putting the numbers into the string array. For example, Bill's scores should be set up as Bill's scores should be set as

Code: bill_score = {3, 1, 4}

and when this code is ran

Code:
for (i=0; i<3; i++) {
printf("%s - ", men[i]);

[Code].....

View 4 Replies View Related

C :: Storing Random Number Into Array

Dec 16, 2014

Code:

for(int i = 0 ; i < SIZE ; i ++)
{
scanf("%d" , & selection[i]);
srand((unsigned) time(&t));
draw[i] = rand() % 50; //feeling could be a problem with this line of code :::::

}

is it possible to do this. i am trying to get 6 different numbers stored into 6 elements of an array . this is the piece of the code i think there is a problem with. ie my program scans the numbers and then crashes at this point so think it could be something to do with the commented line?

View 2 Replies View Related

C :: Storing A Value In Array From Reading In From A File

Sep 12, 2013

Is something like this possible and if not how can I make this work?

fscanf(in, "%d %d %d", &i, &x, &arr[i+x]);

View 4 Replies View Related

C++ :: Array Not Storing Values Properly

Jan 4, 2013

For some reason the integer array, arr[100][50], declared in main is not storing the correct values when passed through the function charArrayToIntArray.

I made an output right in the function to show how the array is not keeping the proper values, although when I output the array from within the loop in the function, it shows the correct values.

/*
infile.txt:
37107287533902102798797998220837590246510135740250
46376937677490009712648124896970078050417018260538
74324986199524741059474233309513058123726617309629
91942213363574161572522430563301811072406154908250
23067588207539346171171980310421047513778063246676 ...........

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <cstdio>
#include <sstream>
#include <iomanip>

using namespace std;
void fileToCArray(string carr[100]); // from text file: inputs the 100 50-digits number into an array of 100 50-character

[Code] ....

View 4 Replies View Related

C++ :: Storing Different Digits Of A Number Into Array Of Int

Oct 9, 2013

The aim is : If i have a natural number [max 5 digits] (say) n=13579. Then a[4]=1, a[3]=3, a[2]=5. a[1]=7. a[0]=9.

I start with a[4]= n/10000 .. then n= n - a[4]*10000;

then a[3]= n/1000. .. n= n - a[3]*1000;

i.e a[i]= n/10^i .... n= n - a[i]*10^i;

To reduce code size i used a for loop. The code is free from any syntax errors.

Its the "output" that is weird. I enter 13579 and what the program process is:
a[4]=1 a[3]=3 a[2]=5 a[1]=8 a[0]=5

Same goes for other numbers too.. leaving the most significant digit , the rest digits are just out of the logic!!

I am using CodeBlocks 12.11 and compiler is GNU GCC compiler.

Here is the output window: [URL] ....

Here is the code:

#include<iostream>
#include<math.h>
using namespace std;
int main() {
int n,a[5],i,t,dec,divisor; // n: storing number; t: copy of n,

[Code] .....

View 2 Replies View Related

C++ :: Storing Integers At Odd And Even Indexes In Array

Mar 4, 2013

here is my problem given below Input values (say 10) from user in array, if the value is even then place at even index else at odd index. Then how could i solve this problem?

View 2 Replies View Related

C/C++ :: Using Functions Storing Sequence In Array

Oct 4, 2014

Trying to make a program that stores a sequence of integers in an array by using functions. This is my code so far:

# include <iostream>
using namespace std;
int Sequence_Length(int seq_length)
{

[Code]....

I get an error in the main, not completely sure how to "call" functions to the main..

View 5 Replies View Related

C/C++ :: Storing IPv6 In Character Array?

Jul 11, 2014

Its been too long since I have had to fiddle bits and I am coming up short.

Bottom line is the new IPv6 ip address representation is of the format:

xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx

These come to me as hex values for example:

2001:7D7E:0000:0000:111A:222B:333C:4444

I want to store this in a char array, of integers of size char_addr[16] where each byte represents the integer representation of each xx pair thus

char_addr[0]=32 (20) *note address above
char_addr[1]=1 (01)
char_addr[2]=125 (7D)
char_addr[3]=126 (7E)
char_addr[4]=0 (00)
...
char_addr[15]=68 (44)

So I am having trouble filling that char_addr array.

View 4 Replies View Related

C :: Storing Array That Is Dynamically Allocated Of A Struct

May 4, 2013

I'm trying to read in a file and store it in an array that is dynamically allocated of a struct (which I'm not sure how to do), then parse each line using strtok() from string.h. The idea is to separate the lines by date, subject, time, etc.

Since the array is a dynamically allocated of typdef struct, it's sorted by the date of each struct, with an intial size of 25. But whenever the array needs to be resized, it should be doubled.

View 1 Replies View Related

C++ :: Array Of Structures - Storing Product Information

Nov 5, 2013

I have been dealing with this problem for quite some time, I've been assigned to develop a program that can store products' information within structures (the number of products is undefined). I thought I should use an array of structures, but I don't know how to declare it properly. This is what I thought would work:

struct product {
string name;
string in_stock;
float sale_cost;
int id; }
prod [n]; //n being the undefined number of products the user will register/delete/modify

I already saw an example of array of structures, but it uses a defined number.

View 13 Replies View Related







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