Programming :: Access Value From Nested Struct <c Language>?
Mar 11, 2010
I having a nested structures which are referenced with pointer variables :
example :
typedef struct {
int a ;
char *b ;
int *c ;
}EXP2 ;
[Code]...
While trying to access the value of sv.exp2->a it throws segmentation fault error.How to acess this variable ??
View 3 Replies
ADVERTISEMENT
May 23, 2011
I have an old C application in which i am trying to include some STL cointainers. When i use the STL container alone it works fine, but when i include it into a C struct i have segmentation faults errors. I know that it is not a good idea to mix C and C++. Considering this code:
Code:
typedef struct{
int shmid;
...
APPLSPACETYPE applSpace;
[code]...
and how to make a malloc for this issue; something like :
Code:
mem->applSpace.rData.completeGroups2zeroGroup=(map_completeGroups2zeroGroup_type *)malloc((sizeof(map_completeGroups2zeroGroup_type)+1)* sizeof(char ));
View 11 Replies
View Related
Apr 8, 2011
Is is possible to use a class inside a struct? I keep getting segmentation fault with this code:
Code:
struct my_struct {
unsigned count;
std::string msg;
[code]....
View 3 Replies
View Related
Nov 6, 2010
I have been spending time (starting yesterday) reverse-engineering GTK+ to get my programming skills up. I came across a struct in the headers (_GtkArg, which was then typedeffed into GtkArg) that includes a union in it that has pretty much the same properties as a struct. Then, there was a struct inside the union.
I'm confused. Just what is the difference between a union and a struct?
P.S. I am using GTK's native C programming language.
View 8 Replies
View Related
Mar 30, 2010
How do we allocate memory of struct? what i did was
Code:
int main()
struct amp
{
[code].....
cout <<"The size of 'struct' is"<< sizeof(struct amp)<<"and it is located at"<<struct amp*s = malloc(sizeof(struct amp))<<endl;
it gives me an error---
In funtion 'int main()':
error: expected primary-expression before 'struct'
error: expected ';' before 'struct'
View 9 Replies
View Related
May 14, 2010
For a work project, I've got a bunch of python code from about a year ago that controls the movement of our EVI-D30 camera over a ttyUSB connection. It used to work fine on a 32-bit Fedora box, but recently we moved our whole project over to a 64-bit Gentoo server, and the same code seems to be worthless on the new platform. I didn't write the code, so I'm have trouble figuring out how to fix it. Error messages usually look like this:
Code:
File "./CameraController.py", line 172, in pan
turn_callback(cmdStruct[0], cmdStruct[1])
File "./CameraController.py", line 147, in turn_callback
cameras[camera].TiltUp()
[code]....
View 13 Replies
View Related
Jan 17, 2011
is there any problem that might rise by by having a vector as a member of struct in c++ as follows.ex.
struct A
{
int a;
[code]...
View 2 Replies
View Related
Feb 8, 2011
Code for insertion of data:
Code:
#include <map>
#include <iostream>
int main ()
[code]....
I don't know how to fetch the data from the nested map here.
View 5 Replies
View Related
Dec 13, 2010
Following is the declaration:
Code:
std :: map <QString, std :: vector <std :: pair <QString, QString> > > configFileDataVector; How should I insert data in it? All the examples which I have looked up in Google are of plain maps!
I tried this, but it failed:
[Code]...
View 4 Replies
View Related
Jul 2, 2010
I following structure
typedef struct
{
[code]...
View 5 Replies
View Related
Feb 5, 2011
I have what should be a relatively simple program (fadec.c) that maps a struct from an included header file (fadec.h) to a shared memory region, but Im struggling accessing members in the struct from the pointer returned by shmat. Ultimately, I want to access members in the shared memory structure with a globally declared version of the struct, shm__. Not only do I not know how to accomplish that, but I cant even seem to access members of the shared struct directly from the pointer itself (compiler complains about dereferencing pointer to incomplete type). Im at a loss and could use another set of eyes if you guys dont mind taking a gander:
Compile Errors:
tony-pc:/cygdrive/p/test> cc -o fadec fadec.c
fadec.c: In function 'main':
fadec.c:30: error: dereferencing pointer to incomplete type
fadec.c:31: error: dereferencing pointer to incomplete type
[Code]...
View 1 Replies
View Related
Jun 2, 2010
int GetTime(struct timeval tv)
{
gettimeofday(&tv, NULL)
printf("%d
", tv.tv_sec); /* here is the right value */
return 0;
}
[Code]....
What happend? struct timeval has a self timer?
View 3 Replies
View Related
Sep 20, 2010
I've only gone into the first case statement of the first switch and I am trying to get out of it but the break statement I added doesn't seem to have any effect and it just goes on to the next case instead of exiting the switch.
Code:
import java.util.*;
import javax.swing.*;
public class A2 {
public static void main(String[] args) {
double gross_Pay;
int payment_Method;
final double salary_Pay = 1000.00;
final double hourly_Pay = 25.00;
double overtime1 = 20.00;
double overtime2 = 30.00; .....
View 2 Replies
View Related
Jan 7, 2011
I need to search through HTML files to count the number of <li> tags nested within the first <ul> tag:
Code:
<ul>
<li>text 1</li>
<li>text 2</li>
</ul>
...
<ul>
[Code]...
Unfortunately, the second grep is greedy swallowing everything up to the last </ul> close tag. (The desired result is 2.) Speed is an issue as I will be searching through 350,000 files.
View 14 Replies
View Related
Jun 18, 2011
the compiler (g++ 4.4.5) does not recognize PRE as a type in the following code:
Code:
enum mode {PRE, IN, POST};
class tree
[code]...
View 9 Replies
View Related
May 26, 2010
Is it possible to create a global struct variable with predefined member values?Only one instance of that struct is ever needed.
View 1 Replies
View Related
May 3, 2010
I want to read a pressed key or a combination of pressed keys from the keyboard and perform some action afterwords.
e.g.
Ctrl-Alt-F1
Out of ncurses lib. and the termios struct which can be used best for the above purpose and why ?I tried to search on Google, the differences between these two but couldn't get much !
View 6 Replies
View Related
May 22, 2010
Code:
tupe=("File",("Open","Open a file"),"Edit",("Cut","Cut a file"),("Paste","Paste a file"),"About",("About","About the program"))
menutitle=""
menupos=0
for items in tupe:
if type(items)==str:
[Code]...
I'm trying to understand how to make "File" be the parent information for "Open","Open a file" and "Edit" to be the parent of "Cut, Cut a file" and "Paste", "paste a file". Does anyone have a suggestion for accessing the a nested tuple in this manner? The above code does not quite do what I want it to. The above code is for visual purposes, but I'm learning how to refactor for wx.python.
View 3 Replies
View Related
Feb 2, 2011
I work in a simulations environment. I'm trying to write a bash script that will read fields from a .csv file into an array, the first field being an identifiyng number and the second field being a corresponding url. There are about 1600 of these number/url combinations in the .csv file that i'm reading from. Once that is done i want it to parse a text file and match the number, when it has a match i want it to enter the corresponding url into a particular line in the text file. The script I have written (with the help of the people on this forum a while back) does this well, but now I have a lot more data to parse. I think the script itself is explanatory enough to see what i'm doing. What i would like to do is cut it down to one while loop nested inside another loop so that I don't have 1600 or so elif statements. I can't figure out how to increment the output of the array. for instance, the first cycle would find the number that matches ${record1[2]} and input the url stored in ${record1[3]}. the next cycle would match ${record1[4]} and input the url in ${record1[5]}, and so on, does that make sense? The code is below and a sample .csv and text file are attached.
[Code]...
View 14 Replies
View Related
Feb 2, 2011
I understand that block_device pointer *bd sholuld get initialized. Program should produce initialization error for *bd. Compiler is producing '->'. I am not understanding why?
[code]...
View 1 Replies
View Related
May 1, 2010
This for Kernel 2.6.29.6. I'm trying to code a kernel module that displays process information.
how to count opened file descriptors per task. I have been able to write a module that lists all the current process names along with their pid number in /var/log/messages. Basically, I cycle through the ring of processes using the macro for_each_process(task) and printk the comm and pid of each task. I'm trying to see how many file descriptors each task has open. I've been reading up in books and all over the internet. At first I thought I needed to access max_fds under files_struct, but that just lists the maximum number of file descriptors that can be opened per task, which by default is set at 256. I then thought about counting the elements in the fd_array. But then I learned that every task's fd_array is initially set at 32. Now I know that I need to access open_fds of type fd_set * in files_struct. open_fds is a pointer to all the open file descriptors. The problem is that I don't know how to access a pointer of type fd_set.
Is there a good guide or book that really focuses on type fd_set and open_fds? Every book and resource I've read never really go into depth on this. relationship between files struct, open_fds, and the open file descriptors in task?
View 4 Replies
View Related
Mar 7, 2010
Groovy is an object-oriented programming language for the Java platform. I do not have experience in Java, only perl and shell scripts. Recently I have been asked to maintain a software written in groovy (also to make enhancements). So can I learn groovy without knowing java language. or isit I have to learn java before venturing into groovy.
View 1 Replies
View Related
Dec 19, 2008
I am unable to find a description of alsa's programing language, this sort of stuff:
[Code]...
I need to know what, for example, 'ttable' means and what is its syntax. This seems to be a state secret.
View 2 Replies
View Related
Mar 27, 2010
I wonder why arrays in the C programming language are pointers to the first element of the array, not the first element of the array itself?
View 14 Replies
View Related
Mar 13, 2009
Is there any framework available for network programming in c language just like POCO in c++.
View 1 Replies
View Related
May 28, 2010
tell me some sites for learning programing language Because i feel confusing for learning C programing language now I got so many questions by my studing and i want to solve them by myself too.
View 14 Replies
View Related
Jun 30, 2010
My name is Simon and I have recently moved Ubuntu 10.04 from Windows XP. I am a programmer with a few years under my belt using a range of languages but primarily Microsoft Visual Foxpro. This program was very useful as it allowed me to access tables stored on my system and create programs to manipulate data in a wide variety of ways. Programs could be hobbled together, refined then placed in a menu system.I have been looking at a range of packages to use that would (a) allow me the same interactive experience, (b) allow me access to xbase tables (especially as most of the packages and business clients I have use this format), and can be used to create a GUI program. Ideally the package could create programs that can run relatively easily on Linux and Windows. Why, you might ask? Well unfortunately I have not been able to ditch foxpro, it is kind of unique in its abilities. Consequently I am using XP in VirtualBox to do some of my analysis and report production. I also still run Windows on my slate computer, which is used in the field to collect data.I have investigated Python/Jython, Java, Bash, and a number of others (e.g things that interact with PostSQL, MySQL, etc) but happily admit that I am overwhelmed with alternatives. That said, none quite match my relatively simple requirements stated above. The biggest problem is the lack of interactive data manipulation -- e.g. type an SQL statement and have the result appear immediately, that sort of stuff.
I need a language with strong data access, manipulation and reporting capabilities. I have sizable tables/databases containing millions of records and at present most queries take only a seconds using Visual Foxpro. Most of my investigations push me to the MySQL and similar data repositories, but all have their own format. Essentially I need to import all my data into their system before a language can access the data (note that there are copyright issues preventing this in some situations) - aren't there any programs that can access dbase or foxpro tables directly?The programming language also needs to be relatively mature. I don't want to spend all my time defining window sizes and button locations. Editors/Wizards that help design a GUI interface is preferable. It is imperative the language also has strong string, number, array and table access capabilities. Code should also be intuitive and easy to read. A lot of the languages I have reviewed are not intuitive. To me, functions in the format substr(string, start, lengthsegment) is logical and easy to follow. Things like Str = ${str//search/replace/} are not.
I suppose while I am listing preferences, an interpreter like eclipse would be desirable to help maintain code and format it as you go. Some sort of intelligent feedback as you construct a code snippet showing you what alternatives are available would also be valuable.At present I am leaning towards Python with Eclipse as the program manager, but as stated this setup does not really provide an interactive experience and does not appear to naturally interact with dbase. It appears this option would require considerable setup to get working.Java + Eclipse has been suggested before, especially as it takes away the need to worry about operating systems, but most of the packages I have used based on this language are restricted by library development by Sun Microsystems. The file chooser is a classic example - a known bug has been registered for this library for 5+ years and the problem has not been fixed.
View 9 Replies
View Related
Jan 21, 2011
I am looking for a specific forum for the R programming language.
Some thing like the LQ is for linux, that will be nice.
Or something like the cplusplus is for c/c++.
View 2 Replies
View Related
Jul 23, 2009
I want to know which is the best scripting language right now and what you guys think its going to be the best or most used in the future, that is, in about 5-10 years. Take into account system administration and applications. This are the languages i had in mind, add more if you think other scripting languages are better or worth considering.
View 14 Replies
View Related
Jun 6, 2010
I use Eclipse 3.5 from Ubuntu 9.10 repository.Please, how to use Eclipse to programming with C++ language?
View 5 Replies
View Related