How to store values from .h files?

I need to read a .h file and store all the values. For example, .h files contain lines like so:

#define mbbh 5 #define gbnn 90 #define mkoll

I wrote some code to read this .h file (where I use string array, search for #define and get the value of the name i.e., ( mbbh, gbnn)- arrayname [1]).

The problem I have is,

  1. If any of these lines doesn't have the value arrayname[2] it throws an exception.

    #define vkol

  2. How would I get the value of #define when it is not in position arrayname[2]?

    #define gbbn 90

This define statement has a value, but how can I get it?

-------------Problems Reply------------

Change

string[] lineParts = string.Split(line, ' ');

To

string[] lineParts = string.Split(line, ' ', StringSplitOptions.RemoveEmptyEntries);

Category:c# Views:4 Time:2018-12-03
Tags:

Related post

  • How to read values from property file in a JavaBean (domain class)? 2011-01-19

    I have a domain class and I want to read values from property file (autowiring messageSource wouldn't work here) so any ideas ? I am using spring,hibernate and here's a sample: package com.myapp.domain; import java.io.Serializable; import javax.persi

  • How to read values from properties file? 2012-02-13

    I am using spring. i need to read values from properties file. This is internal properties file not the external properties file. properties file can be as below. some.properties ---file name. values are below. abc = abc def = dsd ghi = weds jil = sd

  • How to get values from property-file into Map using Spring framework? 2010-08-31

    For now I could inject values from property-files: @Value("${aaa.prop}") public String someProp; But I want something more... For example I have some property file: aaa.props=p1,p2,p3 aaa.props.p1=qwe aaa.props.p2=asd aaa.props.p3=zxc I know for sure

  • Selenium: How to read values from any file (text, excel or csv)? 2011-06-01

    Some of my project data needs to be changed every time i run the script. In order to have automated system i require to read values from any file and send its data as input to selenium script. --------------Solutions------------- If you are using Sel

  • How to store values from a column (in a tab-delimited text file) in Perl 2010-12-09

    Here is an example of the file. Let's say I want to parse the 6th column values and store them in an array. 42 test.example.com activityViewer/index.html 8a699fe62751d158dad57f6b9a3ae5a4 1291836592 4.1938788890839 4 test.example.com activityViewer/in

  • store values from text file into map 2011-04-18

    How do I read strings from a text file and store in a hashmap? File contains two columns. File is like: FirstName LastName Pranay Suyash and so on... --------------Solutions------------- Here's one way: import java.io.*; import java.util.*; class Tes

  • How to store lines from a file into a dynamic array and print? 2011-12-21

    I need, in ANSI C, to open a file, to read all of its lines into a dynamically allocated array of strings, and to print the first four lines. The file may be any size up to 2^31-1 bytes, while each line is at most 16 characters. I have the following,

  • How to store value from JSpinner of Date format into a JodaTime variable? 2012-02-10

    I got a custom class that contains JodaTime's LocalDate variable to hold a date. My swing application has a JSpinner with Date model. I made a button click event so that the date gets stored inside an object's LocalDate data member. Problem is compil

  • How to read values from a word doc file using VBScript 2009-08-12

    Can anyone tell me how to read values from a word.doc file using VBScript. I had given a sample.doc file below. Parameters Default Values ----------------------------------------------------- No of values 8192 Sampling Frequency 12800 Frequency Hop 2

  • how to store data in xml file from textbox in html 2010-08-11

    how to store data in xml file from textbox in html. --------------Solutions------------- You can't in HTML. What processing software are you using? It doesn't make sense to convert the entered xml to html client-side and then submit it to store it. B

  • how to replace strings in file based on values from another file? (example inside) 2011-03-12

    how to replace strings in file, based on values from another file. Example, 2 files - input, output input: 12345 1 output: (1,'a lot of text', 'some other info',0,null, 12345), (2,'a lot of text', 'some other info',0,null, 12345), (3,'a lot of text',

  • How to get a value from resource file using its key 2011-05-10

    How to get a value from resource file using its key --------------Solutions------------- ResourceManager.GetString or ResourceManager.GetStream, depending on the type of the resource. public string ReadResourceValue(string file, string key) { string

  • How to store and retrieve images files from datastore of google app engine in Java 2011-09-21

    Do anyone know how to store and retrieve images files from datastore of google app engine in Java. Hope to get a reply soon. Thanks --------------Solutions------------- http://code.google.com/appengine/docs/java/blobstore/overview.html Exact details

  • ExtJs - How to get value from the Store by id? 2011-10-05

    How to get value from the Store by id? store in such fields fields: [ {name: "id", type: 'int'}, {name: "name", type: 'String'},... I need to get the id - name value. I try so: var rec = Ext.StoreMgr.lookup("MyStore").getById(id); alert(rec.data.name

  • how to pass value from build.xml file to java class? 2011-10-19

    i want to pass the value from build.xml file to java class at run time. We know that we can pass value from command line with ant to the build.xml file. But how to pass this value from build file to java file. We can done it with property file but ho

  • how to read a value from properties file of an enum type? 2011-12-19

    I have an enum as below: public enum EnvironmentType {PRODUCTION, TEST, DEVELOPMENT} in properties file the key value is like : app.environmentType = TEST we know that when i read the value from properties file using key, it returns as String like St

  • How to compare column value from csv file to the column value in mysql table 2011-12-21

    How to check if combination of two column value from a csv are present in a table having csv data in columns ? Example : For every a, b in the csv file: i. Check if it exists in the database NO: Add (a, b, "and other relevant field") to a different t

  • how to read registry string value from batch file 2010-07-06

    I want to read registry string value, from bat file, and then assing the readed value to variable. I tried the following : FOR %%a in ('REG QUERY HKLM\SOFTWARE\MathWorks\MATLAB\7.10 /v MATLABROOT') DO set MATLAB=%%a echo %MATLAB% but it doesn't work.

  • How to store values inside Plist and read while runtime in iphone 3.0? 2010-04-27

    how to store values inside Plist and read while runtime in iphone 3.0?. Thanks in Advance. --------------Solutions------------- If you have an array or dictionary that contains only "standard" data types like strings, dates, numbers, arrays, and dict

  • How to extract values from pdf in .net c# 2010-12-08

    How to extract values from pdf in .net c# and store it in a readable format in .net like text file, html actually i need a pdf parser. --------------Solutions------------- If you need a PDF parser, use one. There are many around - a good free one is

  • Compare values with values from a file? 2011-05-22

    What would be the best way to do this? I have an application that gets two values about each and every 10th second (when user touches the screen). From this i get two values, latitude and longitude of a sphere object that the user has touched. Now I

  • how to read data from dat file? 2010-05-20

    how to read data from .dat files ? i just tried like this memo1.lines.loadfromfile('c:\myfile.dat'); but not worked Note : File type is binary can any one please help me :) --------------Solutions------------- @radick to show the contents of an binar

  • How to generate enum from properties file in Maven? 2010-06-09

    The original title was "How to generate enum from properties file using ant?" I want to iterate over all properties and generate enum class that have every property. Im thinking about writing custom task, but I think i would need to put it in extra j

  • How to pass values from child shell to parent shell 2010-06-22

    How to pass values from child shell to parent shell in shell programming? --------------Solutions------------- This is impossible. The best that can be done is for the child to print the desired assignments, and for the parent to exec them. See my an

  • How to read lines from a file in python starting from the end 2010-08-25

    I need to know how to read lines from a file in python so that I read the last line first and continue in that fashion until the cursor reach's the beginning of the file. Any idea's? --------------Solutions------------- The general approach to this p

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.163 (s). 11 q(s)