Alright, here's what I'm working on now. It's supposed to go through an inputted list of words, pick out actual words and create a numbered list of them, then, where it finds a number in the list, go back in the list from that number, replace it with a word, augment the list accordingly and continue.
Anyways, here's what I have: - #include <stdio.h>
-
#include <string.h>
-
#include <ctype.h>
-
#include <stdlib.h>
-
-
int main ()
-
{
-
char line[100];
-
char word[100];
-
char tword[20];
-
-
int k, index, nwords = 0, j;
-
-
gets(line);
-
-
while(line[0] != '0')
-
{
-
if(isalpha(line[k]))
-
{
-
j = 0;
-
while (isalpha(line[k]))
-
{
-
tword[j] = line[k];
-
j++;
-
k++;
-
}
-
tword[j] = '\0';
-
strcpy(word[nwords], tword);
-
nwords++;
-
}
-
else if(isdigit(line[k]))
-
{
-
index = atoi(line[k]);
-
k++;
-
if(isdigit(line[k]))
-
{
-
index = index * 10 + atoi(line[k]);
-
k++;
-
}
-
printf("%s", word[nwords - index]);
-
strcpy(tword, word[nwords-index]);
-
for(j = index + 1; j < nwords; j++)
-
{
-
strcpy(word[j - 1], word[j]);
-
}
-
strcpy(word[nwords - 1], tword);
-
}
-
else
-
{
-
printf("%c", line[k]);
-
k++;
-
}
-
gets(line);
-
}
-
return 0;
-
}
The problem is that I get segmentation faults when executing. Anybody see what I'm missing?
3 1571 Banfa 9,065
Recognized Expert Moderator Expert
Yeah, I noticed that right after I posted. However, I've changed that now, to no avail.
horace1 1,510
Recognized Expert Top Contributor
an obvious problem is line 28 -
strcpy(word[nwords], tword);
-
word[] is an array of char, it should be an array of char* or char[], e.g. Sign in to post your reply or Sign up for a free account.
Similar topics |
by: John Altland |
last post by:
Hello,
I need to access two databases on two seperate servers in
one program. One, dblocal, and another, dbserver. Once I
am done the queries on the local database, I dispose the
connection to dblocal and attempt to connect, using a
seperate connection. Once I attempt to open this second
connection, an exception is thrown. I used the connection
string built by the server explorer for both databases so
the problem should not be...
|
by: Hp |
last post by:
Hi All,
Thanks a lot for all your replies.
My requirement is as follows:
I need to read a text file, eliminate certain special characters(like !
, - = + ), and then convert it to lower case and then remove certain
stopwords(like and, a, an, by, the etc) which is there in another txt
file.
Then, i need to run it thru a stemmer(a program which converts words
like running to run, ie, converts them to roots words).
|
by: tbatwork828 |
last post by:
Related to my other post on Graphics.FillRectangle and a lot of page
faults caused by this call...
We determine that when Control.DoubleBuffer=true to avoid the flicker
effect, Graphics.FillRectangle causes a lot of soft page faults - order
of 700/sec and more... When Control.DoubleBuffer=false, we have no page
faults at all - 0/sec.
Has anyone seen this behavior and how did they resolve it...? What are
our options...? Does...
|
by: John Mullin |
last post by:
We are having a problem which appears similar to a previous posting:
http://groups.google.com/groups?hl=en&lr=&frame=right&th=d97f552e10f8c94c&seekm=OZw33z9EDHA.2312%40TK2MSFTNGP10.phx.gbl#link1
In the current release of our system, we decided to "wrap" the ASP.NET
Session and Application objects to improve code clarity and accuracy.
For example, instead of:
Session = new SomeListClass;
|
by: WaterWalk |
last post by:
Hello, I'm currently learning string manipulation. I'm curious about
what is the favored way for string manipulation in C, expecially when
strings contain non-ASCII characters. For example, if substrings need
be replaced, or one character needs be changed, what shall I do? Is it
better to convert strings to UCS-32 before manipulation?
But on Windows, wchar_t is 16 bits which isn't enough for characters
which can't be simply encoded...
| |
by: David Morgan |
last post by:
Hi
Have 4Gb of RAM and plenty of free disk.
Those page faults are for DLLHOST.EXE using ~370Mb RAM. inetinfo.exe has
403,106,036 page faults at the time of writing and is using ~145Mb RAM.
Why so many page faults. System uptime ~500 hours.
The ASP-based site does interface with a SQL Server instance on a completely
|
by: Dale Huffman |
last post by:
There have been a number of posts about calling gui methods from other
threads. Eric Brunel. has reccommended calling the gui's
..event_generate method with data passed thru a queue. This worked
great for me until trying to write to the gui from multiple threads.
There I had problems: random typesof crashes almost all resulting in
seg faults. I thought this info might help anyone trying to do the
sameor at least save some time...
|
by: scotp |
last post by:
Does anyone know what would cause excessive page faults
running the js function below? The most common browser used
is IE 6. The page has records that include text & checkbox
inputs. Each record also has a hidden input named
"questions", whose value is an id that is used in the name
of inputs to be disabled. The number of page faults
increases dramatically as records increase. I know it is
the for loop that is taking the extra time,...
|
by: none |
last post by:
I have an ASP.NET application, hosted on two web servers. I am looking
for advice on what should be an acceptable level of page faults on
these production servers. If the acceptable level is zero, then where
should I begin reducing page faults in code? What should I look for in
code to reduce page faults?
Having to reduce page faults is something I have not had been tasked
with before, so I am not sure what is acceptable and where to...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |