is it correct to write that: -
-
-
fscanf(InputFile, "%s %d %d", NewVertex->CarId, NewVertex->x, NewVertex->y);
-
-
6 1080
is it correct to write that: -
-
-
fscanf(InputFile, "%s %d %d", NewVertex->CarId, NewVertex->x, NewVertex->y);
-
-
The *scanf family of functions need an address to store their scanned and converted
values to, so if your expressions result in an char*, int* and an int* everything is fine.
kind regards,
Jos
hence i dont no where is the problem in those lines of code: - for(i = 0; i < vehicules; i++)
-
-
{
-
-
NewVertex = CreatVertex();
-
-
// up to here ok
-
-
fscanf(InputFile, "%s %d %d", NewVertex->CarId, NewVertex->x, NewVertex->y);
-
-
}
-
-
this is the file:
5
250
Toto 25 50
Foo 20 50
X 50 100
Y -100 -200
Z -5 150
the program cruch
What is the type of 'NewVertex->x'? If it is an int* you're fine; otherwise you'd
better pass the address of that variable to your *scanf() function. The same
reasoning applies to your NewVertex->y variable.
kind regards,
Jos
am trying to impliment a linked list to hold a graph (2D linked list col for vertices and rows for edges...)
is this structer correct? - typedef struct _list list;
-
-
struct _list
-
{
-
edge *E;
-
vertex *V;
-
list *NextVertex,
-
*NextEdge;
-
} ;
-
or: - typedef struct _edge edge;
-
typedef struct _vertex vertex;
-
typedef struct _edgelist edgelist;
-
typedef struct _vertexlist vertexlist;
-
-
struct _edge
-
{
-
CarID[10];
-
int distance;
-
};
-
-
struct _vertex
-
{
-
CarID[10];
-
int x,
-
y;
-
};
-
-
struct edgelist
-
{
-
edge *E;
-
edgelist *next;
-
};
-
-
struct edgevertex
-
{
-
vertex *V;
-
vertexlist *next;
-
};
-
if you have any better implimentation please help!
originaly am using these structers to impliment my graph: - typedef struct _edge edge;
-
-
typedef struct _vertex vertex;
-
-
-
-
struct _edge
-
-
{
-
-
char CarId[10];
-
-
int distance;
-
-
edge *NextEdge;
-
-
};
-
-
struct _vertex
-
-
{
-
-
char CarId[10];
-
-
int x,
-
-
y;
-
-
vertex *NextVertex;
-
-
edge *NextEdge;
-
-
};
-
-
how should i buil my 2D linked list ?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Psibur |
last post by:
Hello, trying to get back into c and was having issue with reading a
simple text file with an aribtrary # of lines with 3 int's per line,
with the eventual purpose of putting each int into an...
|
by: Thomas Sourmail |
last post by:
Hi,
I hope I am missing something simple, but.. here is my problem:
I need my program to check the last column of a file, as in :
a b c d target ref
0 0 0 0 1 a
1 0 0 0 1.5 b
2 0 0 0 2 c
|
by: PeterOut |
last post by:
I am using MS Visual C++ 6.0 on Windows XP 5.1 (SP2).
I am not sure if this is a C, C++ or MS issue but fscanf has been
randomly hanging on me. I make the call hundreds, if not thousands,
of...
|
by: David Mathog |
last post by:
Apologies if this is in the FAQ. I looked, but didn't find it.
In a particular program the input read from a file is supposed to be:
+ 100 200 name1
- 101 201 name2
It is parsed by reading...
|
by: momotaro |
last post by:
I have a small problem with the last fscanf in this function...every thing is logic in there but can't find the problem... plz help
node *BuildGraph()
{
int range, vehicules, i, j,...
|
by: Shisou |
last post by:
Hey bytes community!
this one is a really strange issue I ran into and I'm hoping you all can shine some light on it for me.
This is written in C, not C++
I'm working on a program that reads...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |