C :: 2D Array - Input Seems To Lag One Behind When Inserting Data

Jan 27, 2014

For some reason, my input seems to lag one behind when inserting data. Attached, I have code that I wrote along with the example of the lag. What may be wrong with my code that is causing this to lag?

View 7 Replies


ADVERTISEMENT

C++ :: Inserting User-input String To Array

Nov 8, 2014

I'm trying to code the program that will store item data.And I'm having problems to receive user-input string to array.

#include <iostream>
#include <cstdlib>
#include <cstring>
#include <string>
#include <iomanip>
using namespace std;

[code].....

View 6 Replies View Related

C Sharp :: Inserting Data Into Database And Display In Gridview

Feb 12, 2014

using System;
using System.Collections.Generic;
using System.ComponentModel;

[Code]....

find the attachment.

Data is displaying in grid view but when i enter the particulars it's not inserting in to DB & grid view.

View 1 Replies View Related

C/C++ :: Inserting Elements Of Array Into Another One?

Jan 16, 2014

#include "stdio.h"    
char t[16] = {0x8F,0x78, 0xC6, 0x12, 0xBA,0x98, 0xA2,0x16, 0x8F,0x78, 0xC6, 0x12, 0xBA, 0x98, 0xA2, 0x16} ;
char w[44];  
void main(){  
    for(int i=0 ; i<4 ; i++){  
        w[i] = (t[4*i], t[4*i+1], t[4*i+2], t[4*i+3]);
        printf("%0x ",w[i]);  
    }
}

i want to put some elements of the t array into the w array but when i do this, it prints only t[4*i+3]

i want the output to be something like this

w[0] = t[4*i], t[4*i+1], t[4*i+2], t[4*i+3] = 0x8F,0x78, 0xC6, 0x12
w[1] = 0xBA,0x98, 0xA2,0x16
and so on

View 2 Replies View Related

C++ :: Inserting New Element Into String Array?

Nov 19, 2013

I have the structure defined in the code below and need to insert a new string into the middle of the string array. I know there is a way to insert a new element with a vector. How to do this. I have tried several variations similar to uniqueList.word.insert(400,"disisdabomb"); but with no luck.

const int maxWordCount=1500;
struct wordCountList
{
string word[maxWordCount];
int count[maxWordCount];
};
wordCountList uniqueList;

View 2 Replies View Related

C :: Inserting Escaped Characters Into Char Array

Apr 19, 2014

Below is an extracted portion of an example exercise from the C Programming Language book:

Code:
void escape(char * s, char * t) {
int i, j;
i = j = 0;

while ( t[i] ) {
switch( t[i] ) {

[Code] ....

Here's my problem with this. s is a pointer to a char array. That means each index stores 1 byte. A backslash character '' is one byte. In above example, we escape it with a second backslash character: ''. That means we have two bytes there. So why does it allow inserting two bytes into a one byte index?

View 3 Replies View Related

C++ :: Priority Queue - Inserting Into Bottom Of Array

Jan 24, 2013

i am working on creating a priority queue, i seem to have done the algorithm for inserting from the top correctly but the algorithm for inserting from the bottom doesnt seem to work it just overwrites the existing data.

below is my code :

list is an array and listlength is the size of the array declared as a integer

void inserttop(string task) {
//int head = 0 ;
string temp ;
listlength++ ;
for (int i = 1; i < listlength; i++) {

[Code]...

View 2 Replies View Related

C++ :: Unable To Input Data From TXT File Into Array Program

Mar 26, 2013

I'm having issues trying to input data from a .txt file into my array program. The whole program takes the name, # of goals and assists, adds them together to get points, and then puts in a given + or - rating. The program works except for the data input.

Also, this is an alphabetical "Unsorted" list, but is there a way to order the list based on point value and be able to display that as well as a separate "Ordered" list?

#include <iostream>
#include <iomanip>
#include <fstream>
#define NUM_PLAY 30
using namespace std;
int buildArrays(int[], int[], int[]);
void printArrays(string[], int[], int[], int[], int);

[Code]...

And this is the .txt file. Order is Players Name, Goals, Assists, Plus/Minus rating. The points are added when points = goals + assists (Should be in the main coding above).

Bryan_Bickell 2 5 +2
Brandon_Bollig 0 0 0
Dave_Bolland 4 2 -1
Sheldon_Brookbank 0 0 -1
Daniel_Carcillo 0 1 +3

[Code]...

View 5 Replies View Related

C++ :: Putting Data Into Array Using For Loop From Input File?

Jul 7, 2014

I'm trying to pass several integers into the array idAr[10] from an input file using a for loop and then having them output on the console. The output should look like this:

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

[Code].....

View 4 Replies View Related

C++ :: Data Input Into A Text File While Not Deleting Original Data

Apr 19, 2013

I want to input data into text file while not deleting the original data in the file and I use something as

ofstream writefile;
writefile.open("example1.txt");
if (writefile.is_open()) {
for(j=0; j<N; j++) {

[Code] ....

But this will delete the original data.

View 3 Replies View Related

C :: File Operations - Fwrite Padding Extra Data In File Compare To Data Provided As Input

Oct 28, 2014

I am trying to write my files to another subfolder . Below is my program.

Code:
cat th6.c
#include <pthread.h>
#include <stdio.h>
#include <string.h>

#define SIZE 8
#define NUMELM 8

[Code] ....

I observe my filename along with directory as text in the new file created in sublfolder. This is output.

[cporgs/apue/threads]: mkdir first
[cporgs/apue/threads]: ./a.out test.txt first
test.txt -- first/test.txt
dfdfdfdfdfdfdf-14
dfdfdfdfdfdfdf-14
in thread test.txt first
[cporgs/apue/threads]: cat first/test.txt
dfdfdfdfdfdfdffirst/test.txt
[cporgs/apue/threads]: cat test.txt
dfdfdfdfdfdfdf

I could not able to get from where this filename and folder is getting added.

View 4 Replies View Related

C++ :: Inserting A Row Into A Matrix?

May 1, 2013

I'm writing a function that inserts a row into a matrix and deletes the last row.

But I'm having trouble. What do I need to add to this function:

View 1 Replies View Related

C++ :: Inserting Into A Vector Which Is In A Map?

Jan 30, 2013

I have a program that stores values in a map>. I use the map as a dictionary so that I can look through my map if a perticular string already exists. If a string does exist, I want to put the position that I found it at (relative to my text file) in my vector. How do I do this? So far I've tried this:

void mapInsert(string aWordNoSpaces, int index){
// check if word exists in map already, but first we need an iterator object
map<string,vector<unsigned int>>::iterator it;
it = wordMap.find(aWordNoSpaces);
if(it == wordMap.end()){
wordMap.insert(pair<string,vector<unsigned int>>(aWordNoSpaces,index));

[Code]...

Also, why are the zeros showing up here (i've attached a screenshot and circled them): [URL]...

View 5 Replies View Related

C :: Inserting Unique IDs In Structure

Aug 11, 2014

I've used qsort to extract the unique student IDs by jumping every four because there's 80 rows of data and twenty students.

I want to make sure it's all working and there's something very strange going on. If you look at my code, when it comes to initialising the structure with the unique student IDs it will happily print them after each one has been initialised inside the for loop (which suggests to me it's obviously done it) but, however, when I want to print them again outside the for loop in another for loop as a "double-check" it goes horribly wrong, presumably they're not in there at all? If you traverse the code to the bottom you'll see my comments.

Now in my for loop, j is going to be incremented 20 times which will correspond to the #define STUDENTS 20. So imagine the array of structure db[j] , the first loop will set i and j both to zero, retrieve the first unique ID and store it in the structure. Then i is incremented by four to acces the next unique ID and then j is incremented by 1 to insert this new ID in the structure.

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

[Code]....

View 3 Replies View Related

C :: Inserting Text Into A String

Jun 11, 2013

I have a pointer to a C string that contains multiple lines of text. I need to change a few characters in the string (possibly adding 1-2 extra). At the moment my code looks like this (char **objectData is the pointer):

Code:
char temp[350];
char* end = strstr (*objectData, "word_before_data_changes");
strncpy (temp, *objectData, 39); // Copying the first 39 symbols
strncat (temp, "6-11", 4); // inputting some data
strncat (temp, end, 100); // copying the last symbols.

I don't know how many there would be. Tried sizeof(end), but this cropped off last two lines for some reason. So using 100 at the moment. This sort of works, but I think it also adds some new lines or null-terminating characters in the end or something like that, because data parser cannot parse the modified data after that.

View 14 Replies View Related

C++ :: Inserting Math Functions From GUI

Feb 8, 2013

I have a problem with entering math functions in my Bisection method algorithm program. I just don't know how can I make the function that I enter in my GUI app to go from the GUI to the loop and find the root.As far as I googled I only find codes that you need to pre-enter a function in the double/float.

For example:I have a function f(x) = x^3 - cos(x) - x - 3; and I want to enter that function trough the GUI i made in c++..So this is the main code.

#include "bisection.h"
#include "ui_bisection.h"
#include <QFile>
#include <QString>
#include <math.h>
#include <algorithm>
bisection::bisection(QWidget *parent) :

[code]....

View 11 Replies View Related

C/C++ :: Error While Inserting In Map Of Vector

Apr 1, 2015

#include<iostream>
#include<vector>
#include<map>
using namespace std;
class foo {
struct type {
int i;
string s;
}y;

[Code] ....

In the sample code

1) why can't we use union if its members have constructors
2) I am not able to insert in Map.
3) also I am not able to use object of struct type y to assign value of its members and later push_back in vector
I am getting following error

knils@knils-HP:scott_mayers$ g++ vector_of_struct.cpp
vector_of_struct.cpp: In member function ‘void foo::fun() const’:

[Code] ....

View 3 Replies View Related

C/C++ :: Display Data From File Into 2D Array - Print Closest Bmi From Data

Mar 28, 2015

#include <iostream>
#include <fstream>
using namespace std;
int main() {
int r = 0;
int c = 0;
int num[17][15] = { 0 };
[Code] ...

// Here is my code for displaying the data from the text file into a 2d array and height next to it, but I am not able to diaplay the height from 60 to 76 next to the row of the 2d array, as shown in the table below. This is my program:

Recently the health authorities have listed a new way to calculate the body mass index (BMI) of an individual.
Values of 20 – 24 are classified as normal, 25-29 as overweight, and 30-34 as heavy.

The table below is a portion of a typical BMI table.

BMI:202122232425262728293031323334
Height:
60102108113118123128133138143149154159164169174
61106111116122127132138143148153159164169175180
.
.
.

MY task is to write a program that does the following things:

1.Produce the table by reading in the data from bmi.txt (on Moodle) into a 2-D array.

2. Display the table neatly on the screen, with row and column headings. The BMI should go from 20 to 34. The height should go from 60 to 76 inches.

3. Prompt the use for their height (in inches) and their weight.

4. Make the program print the closest BMI.

If their weight is lower than the values on the table, use 20 as the BMI.
If their weight is higher than the values on the table, use 34 as the BMI.

5.Loop the program so the user can find more BMI’s.

View 7 Replies View Related

C++ :: Inserting Elements In A Set With Type Pair

Jan 8, 2013

I want to use a dataset of type set which will have the type pair<char,string> or pair<string,string>. How can i insert values into the set, because i have to initialize the set and will not change the set during the program.

View 3 Replies View Related

C++ :: Inserting Hex Value And Sending It At Serial Port

Dec 17, 2013

I am trying to convert decimal value 1 to 32 to hex value and insert it at 4th pos of char array and send it as hex value at the serial port .

My issue is it is converting to decimal to hex value but when it sends, it treat the converted hex value as char and sends it equivalent hex value.

For example

if decimal =1 then its hex = 1.
so , writebuffer[3] =1

But when we send whole writebuffer through send function, it treat this 1 as char and sends its hex value as 31. how to send its hex value.

unsigned int i=0;
char hex[3];
unsigned char hexunsigned[3];
unsigned int dec;
do {
unsigned char writebuffer[8] ={0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

[Code] ....

The send function is

void serial::send(unsigned char data[], DWORD noOfByte) {
DWORD dwBytesWrite;
WriteFile(serialHandle, data, noOfByte, &dwBytesWrite, NULL);
}

View 2 Replies View Related

C++ :: Inserting Structure In Binary File I/O

Mar 28, 2014

I'm trying to insert a structure into a binary file, then read it back out into a "temporary" structure and output some values.

#include <iostream>
#include <fstream>
using namespace std;
struct b_tree_node {

int num_keys; // number of keys in this node
int key_val[3]; // key values (0 to num_keys - 1)
int child[4]; // child file addresses (0 to num_keys)

[Code] ....

View 12 Replies View Related

C++ :: Data Input From Txt

Nov 27, 2012

I have this code.

Code:
#include <string>
#include <iostream>
#include <fstream>
#include <math.h>
#include <sstream>
string scoresort[9];
int HighScore(int PlayerScore){

[Code] ....

Now I can't put data into the array scoresort[x]. I have tried everything. When the scoresort[x] is not an array I can input data. Although when it is an array it crashes my program. It will not process the line.

This is part of the HighScore section for a game that I am currently making.

View 1 Replies View Related

C :: Inserting String At Index In Linked List

Feb 17, 2013

I'm trying to make a function that lets me pass an index and a string and will insert the string at that index in the linked list...

Code:
typedef struct node {
char* value;
struct node* next;
} LinkedList;
void llAddAtIndex(LinkedList** ll, char* value, int index) {

[Code] .....

View 6 Replies View Related

C :: Inserting Element In Binary Tree Using Pointers

Sep 7, 2014

I want to insert an element into binary tree using pointer passing through functions. In my program i have used three structure which are follows :-

Code:

struct tree{
int data1;
struct tree *leftptr;
struct tree *rightptr;
};
struct list{
struct tree **data;
struct list *node;

[Code]...

Here i think problem is in allocating memory to n2 . why i do this because i want to store the address of address of left and right pointers of tree and extract that address to get the address of left and right pointers. Is my method correct ?

View 2 Replies View Related

C++ :: Inserting File Of Names And Sorting Alphabetically?

Feb 25, 2013

A teacher has asked all her students to line up single file according to their first name. For example, in one class Amy will be in front of the line and Yolanda will be at the end.

Write a program that will read in a file of names. Names should be read until there are no more names to be read. Use LineUp.txt as a test file for your program.

Once all the names have been read in display which student will be at the front of the line and which one would be at the end of the line. You may assume that no two students have the same name.

These are the name in the LineUp.txt file if needed:
Cooper
Gavin
Joseph
Sierra
Kacie
Dylan
Kaylee
Will

and so on .....

View 1 Replies View Related

C++ :: SQLite3 Insert Function (not Inserting Values)

Jan 24, 2014

I am using c++ with sqlite3

I have a database(test.db) with a table of testTable

inside the testTable it has the following attribute

_id|randomText

I tried inserting a randomText into the database after my input but it's not inserting into the database.

my code [URL]

View 2 Replies View Related







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