C Sharp :: Displaying Text File Block By Block In C#

Dec 21, 2012

I have a text file that is divided into blocks:

#1
1:animal
2:food
3:moves
4:oxygen

#2
1:eats:2
2:breaths:2
3:can:1
4:is a:1

#3
1:1:2
1:3:3
1:2:4

And the following program that displays block by block:

StreamReader streamReader = new StreamReader("G:LAB123LABWORK2.txt");
            int block = 0;
            while (!streamReader.EndOfStream)  {
                string line = streamReader.ReadLine().Trim();
                if (line.CompareTo("") == 0)

[Code] .....

My problem is am supposed to add a verification code so that if i put a string e.g 1:?:? it returns the block where the string is found and gives of all possible answers.

Attached Files : LABWORK2.txt (240 Bytes)

View 2 Replies


ADVERTISEMENT

C++ :: Block Internet Access To A PC?

Jun 18, 2012

I need to turn off internet access for SPECIFIC website locations. I use C++ Builder 2010 or Delphi 2010.

View 5 Replies View Related

C++ :: Multiple Comparisons In One Block

Aug 9, 2012

Here's my program bake.cpp(name does not reflect content) I've been researching this binary error and haven't been able to find a solution...

Code:
#include "stdafx.h"
#include <iostream>
#include <string>
#include <conio.h>
using namespace std;
int main() {
//Display a list of options.
cout << "Choose your favorite:" << endl;
[Code] ....

Error code..

1>------ Build started: Project: bake, Configuration: Debug Win32 ------
1> bake.cpp
1>c:usersjonbecherdocumentsvisual studio 2012projectsbakebakebake.cpp(41): error C2784: 'std::basic_istream<_Elem,_Traits> &std::operator >>(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'std::basic_ostream<_Elem,_Traits>'

[Code] .....

View 1 Replies View Related

C :: Clrscr Function In Code Block

May 1, 2014

I start working on CodeBlocks and stuck in a situation. The situation is that I want to clear my output screen every time the main function calls some other functions. To do that I use clrscr() function but its not working. After spending some times on web, I found that its a non-standard function so this extension is not used by the new compiler's. Another thing I find to use < cstdlib > library. But unfortunately it do works only for C. It works for C++.

View 2 Replies View Related

C# :: Block Program From Seeing Process Tree

Dec 7, 2011

I have a program that I can only run one instance of. When I try to start it a second time, it doesn't do anything. I would like to create a script that loads the program in a way that I can run multiple instances. Since I assume the program checks the process tree on startup to see if an other instance is already running, I figure disabling access to the process tree could do the trick.

View 6 Replies View Related

C++ :: Passing Block Of Char To Variable

Sep 8, 2014

#include<iostream>
using namespace std;
int main(){
int size_col = 12;
int size_row = 12;
char months_array[12][12] =

[Code] ....

I am having problems with passing a block of a char to a variable, so i could print it out.

It gives me an error: value of type *char cannot be assigned to a entity type char.

View 7 Replies View Related

C/C++ :: Looping Entire Block Of Code

Feb 3, 2014

I just want my program to run continuously until someone enters 0 to exit it. I tried doing while(x=1) and looping my entire block of code. Also there is a switch one is a for one is a while loop both doing the same function. I have basic error checking and whatnot.

/*This is a program that gets a user to input a starting and ending value.
The code then prints the number ie 1 and 5 would be (1,2,3,4,5) and all the squares and cubes.
There is a case statement asking weather you want to run it as a for or as a while loop.
The choices are case sensitive.
*/

#include <stdio.h>
#include <stdlib.h>
#include <math.h>//allows for power and cube function
int x;
int main(){

[Code] ....

View 4 Replies View Related

C++ :: Implementing Signature Block Class

Sep 29, 2013

For class we are required to implement a signature block on all our assignments. To do this I've created a Signature Block class, but I'm having trouble implementing it. When I try to compile in Dev C++ I get this error:

[Error] request for member 'toString' in 'myblock', which is of non-class type 'SignatureBlock()'

Here is the code:

Assignment1.cpp

#include <iostream>
#include <string>
#include "SignatureBlock.h"
// Assignment 1: Requests user's name and says "Hello."
using namespace std;
int main(int argc, char** argv) {
string name;// string to store user's name
SignatureBlock myblock();// create a signature block object

[Code] ....

View 4 Replies View Related

C/C++ :: Illogical Results By Using Try And Catch Block

Oct 24, 2013

there are illogical results by using try and catch block

#include<iostream>
using namespace std;  
class Circle_computations {  
public:
    double area,circumference,radius,pi;  
public:    
 Circle_computations() {

[Code] ....

View 1 Replies View Related

C/C++ :: How To Find Output From A Block Of Code

Feb 2, 2015

int a = 9, b = 4, c = -1;
c *= --b * a;

View 1 Replies View Related

C++ :: Control Execution Of Code Block By Entry

Apr 25, 2013

I have a program including several code blocks in the following simplified structure:

int main() {
// block A
if(a > 0) {
}

// block B
if(a > 1) {
} }

Block A and B should be executed separately, according to entry from keyboard. For example, if entry "1", block A will be executed and block B will be ignored; if entry "2" the inverse will happen.

I can control the execution of these two blocks through macro but the code will be separated during compilation. But is there a way to control them without using macro?

View 4 Replies View Related

C++ :: How To Skip A Block Of Commands When User Interrupts

Nov 3, 2014

I am working on a program that does something like this,

Void main() {
cout<<"H";timedelay(1);
cout<<"E";timedelay(1);
cout<<"L";timedelay(1);
cout<<"L";timedelay(1);
cout<<"O";timedelay(1); //timedelay(int a) is a function which gives a delay of 'a' seconds.
{
....
}
}

This code is just for fancy and I would like to squish in some statements which would give the user an option to skip it (by entering any keyboard key),and resume with the rest of the program.

View 10 Replies View Related

C/C++ :: Boost Dynamic Bitset Block Size

Mar 12, 2012

I am designing an application in which I need to deal with many different variables in which different sequences of bits are stored. I have very strict memory requirements so I decided to use the boost::dynamic_bitset data type which works very well in my scenario as I need to dynamically allocate/deallocate/resize the variables.

The only problem is that I am not able to change the size of the blocks in which the dynamic_bitsets are stored.

I mean, even if I specify the blocks should be "unsigned char", I always obtain 32 bytes allocation by sizeof function, even if the variable is empty.

View 3 Replies View Related

C++ :: Shortcut For Commenting Out A Large Block Of Code

Feb 11, 2013

Is there a quick shortcut (like CTRL+something) to comment out/ decomment a large block of code in Dev C++ when it is selected?

I find it tedious to go line by line and add the // in front of each line.

View 3 Replies View Related

C++ :: How To Print Any Input Year In Digital Block Form

Apr 29, 2013

How to print a year like DIGITAL CLOCK NUMBER for any input four digit number ...

For example if input 1000 the output should be 1000 but each number should look like this in the block form for example number 0 is, don't mind those stars, i did not know to print it here, that is number zero ...

======
=****=
=****=
=****=
======

View 1 Replies View Related

C++ :: Point / Line And Block - How To Design Data Structure

Mar 27, 2014

Suppose, I have point_c, line_c and block_c three classes:

class point_c {
public:
double x, y;
};

class line_c {
public:
vector<point_c> Pt;

[Code] ....

As you can see, lines are composed of many points, and blocks are composed of lines and points. And I defined some member functions, so that I can add points or lines as required by line and block.

But, here comes the problem, if I use line.insertPoints(), or block.insertPoints(), the points will be stored in line or block. That is not what I want.

I want have a single place to store all points, a single place to store all lines, and a single place to store all blocks.

Then I guess I need some global variables

vector<point_c> Pt;
vector<line_c> Ln;
vector<block_c> Bk;

And I should change the classes into:

class point_c {
public:
double x, y;
};
class line_c {
public:
vector<size_t> PtIndex;

[Code] .....

in this way, the member functions will create the real entities into the global vector and set an index pointing to that entity. But this approach just make me feel it is not OOP anymore. when people using these classes, they got be careful about the global variables.

View 7 Replies View Related

C# :: (Grid) Stop User From Clicking Past A Certain Amount Of Block

May 21, 2014

0
down vote
favorite

So, I'm attempting to create a grid on the screen, and to do so, I've implemented a multidimensional array of Rectangles. When the program starts, I use a for loop to increase the x and y coordinates to form the grid.

public Form1() {
InitializeComponent();
for (int x = 0; x < 12; x++) {
for (int y = 0; y < 12; y++) {

[Code] ....

My issue is trying to figure out when the user has clicked on a rectangle, and furthermore, which rectangle in the array that he/she has clicked on. As I will change the border to red when given the correct rectangle.

I'm using Visual Studio 2008, and here is my code so far.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;

[Code] .....

I'm making this into a real game, with classes and all.

View 7 Replies View Related

Visual C++ :: How To Surround Memory Allocation Area By Try-catch Block

Aug 6, 2013

I am using new operator, I don't recall what the allocator's name is. But what is the corresponding Exception (or derived classes) any try-catch block can cope with?

View 1 Replies View Related

C++ :: Create Data And Saves It Into Block - fstream Appearing To Not Function Properly

Apr 14, 2013

I'm working on a program which creates data and saves it into blocks (different files), then reloads and converts it all. the .ftl file saves properly, but for some unknown reason, it won't let me open it for input after.

Here's the significant code:

#include <iostream>
#include <fstream>
#include <string>
#include <sstream>

stringstream filename;
stringstream newfilename;
string Filename;

[Code] ....

setblock will typically = 3, but for testing purposes is set to 1. this really has me confused. the compiler i'm using is Dev-C++ 5.2.0.1 on xp. i have tried pausing the program after the output file is closed, confirming the file has been created in the proper directory before continuing but still fails the .is_open() check.

View 4 Replies View Related

C++ :: Displaying A Text File (Echo)

Jul 19, 2013

So I'm really stuck trying to figured this bug on the program that is preventing me from displaying the text of my program..

#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <stdio.h>

using namespace std;
int main () {
ifstream infile;
ofstream offile;

[Code] ....

View 3 Replies View Related

C :: Displaying A String Loaded From A Text File

Jan 19, 2014

I'm working on a program that can load all words from a dictionary "English2.txt" (it's attached to the post), then put every word into a 2-dimensional matrix (every line is reserved for one word) and display them. After loading every word into a matrix, when I try to display first 8 words with printf, I can't do it without '' at the end of a line. Otherwise only the 8th word is displayed... What's more, when I try to read the length of the first word with strlen, it says, that it has 4 characters (in fact there are only 3 and it's the word "AAA"). What could be the reason for that?

Code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
int main()
{
FILE *fp;
char buffer[32];

[Code]...

View 4 Replies View Related

C++ :: Code For Displaying Text File Not Working

Dec 6, 2013

i have turbo c++ 3.0 installed . my program is compiled without error and is running. but when i choose option to display scores in the consol , it hangs . check my code. i have to run this on same compiler. i just want to display all the contenets of text file .

#include<iostream.h>
#include<conio.h>
#include<stdio.h>

[Code].....

View 4 Replies View Related

C# :: Adding And Displaying Data From A Text File

Mar 6, 2014

Is it possible to display data from a textfile and also save data in to a textfile, reason being is for me to create back-ups of data into a textfile hidden somewhere in a safe location in the local disk or server in case of database error and failure.

View 3 Replies View Related

C Sharp :: Substring From Number In Text File

Oct 15, 2013

How to substring first 8 digits from number?

I have text file with around 10k lines. Each line contains number with length 12-14 digits. I want to take only first 8 digits from each number and writ it in new file.

View 1 Replies View Related

C Sharp :: How To Get Text From Node In XML File That Contains Text And Child Node

May 21, 2013

I have a very big xml file. I read it using by xmlReader. I have problem when i reach to next line:

<title>Abasia<nemod>(-astasia) (hysterical)</nemod></title>

How I can read all that content. I have to have next string at the end: "Abasia (-astasia) (hysterical)".

I tried to use ReadElementContentAsString() for all elements, but elements like this has exception, because it has child element.

View 1 Replies View Related

C Sharp :: How To Select Specific Rows And Columns From A Text File

May 29, 2014

I want to select three columns from my text file i.e. Empl No, Start Date and Created Date. After selecting this, I want to insert the data into a database.

I have attached a copy of the text file.

I have the following code so far:
 
 if (File.Exists(filename))
                {  
                    string[] lines = File.ReadAllLines(filename);
                    for (int y = 0; y < lines.Length; y++) {    
                        Console.WriteLine(lines[y].ToString());  
                    }    

How do i select specific details for each employee

View 1 Replies View Related







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