C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old March 2nd, 2002, 05:35 AM
kreyes kreyes is offline
dark angel
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Location: in your mind....
Posts: 2 kreyes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy whats this warning mean?and how to search keyword...

im running a prog.on linux c BUT keep on gettin warning msgs: Ansii c++ prohibits void* conversion
in the malloc part of the linked list.
ex.pNew = malloc(sizeof(structGNodeType));

im also tryin to make a code that given a keyword it will search for its instances in all the Questions(take note that words in the question are seperated by a space)-my code here runs but doesnt seem to get any match though im pretty sure the keyword i entered has a match.anybody help??

int find(ptrGNode pGame)
{ ptrGNode pTemp;
int nCtr,i,j,k,l,m,nVal;
str70 strTemp;

char sKey[31];
int nFound=0,nWhere;
nCtr =0;
do{printf("\n\n Enter Keyword:>");
scanf("%s",sKey);

if(strlen(sKey)>31)

printf("Keyword must only be 30 characters or less");

}while(strlen(sKey)>31);
if(sKey[0]=='\0')
return(NOT_FOUND);
else
{pTemp=pGame;
j=0;

while(pTemp!=NULL)
{
for(i=0;i<strlen(pTemp->sGame.strQuestions);i++)
{
while(pTemp->sGame.strQuestions[i]!='\0')
{
strTemp[j]=pTemp->sGame.strQuestions[i];
j++;
}
strTemp[j]='\0';

if(!strcmp(strTemp,sKey))
{
nFound=1;
return(nCtr);
}
else
nCtr++;
pTemp=pTemp->pGNext;
}
}
}
if(nFound==1)
nWhere=nCtr;
else
nWhere=NOT_FOUND;

return(nWhere);
}





/*Function: view_Keyword *
* Purpose: this function displays the question matching the keyword *
* Note: Calls the function int find() */

void view_Keyword(ptrGNode pGame,struct_Game sGame)
{ptrGNode pTemp;
int nNum,nChoice;

pTemp=pGame;
do
{printf("\n ~ ~ ~ ~ ~ VIEW KEYWORD ~ ~ ~ ~ ~ \n");
nNum = find(pGame);
if( nNum==-1)

printf("not found!");
else

display_Question(pTemp->sGame);
printf(" Would you like to look up another(1-yes/0-no)?");
scanf("%d",&nChoice);

if(nChoice==1)
view_Keyword(pGame,sGame);
else if(nChoice==0)
view_Question(pGame,sGame);
else
puts(ERROR);
}while(nChoice==1);

Reply With Quote
  #2  
Old March 2nd, 2002, 11:56 AM
WoR WoR is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Posts: 23 WoR User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
new and alloc function return void* pointers.

since your struct/class member pNew likely has a different type you have to explicitly typeconfvert.
Say pNew is a pooiinter to int write:
ex.pNew = (int*) malloc (...);

Reply With Quote
  #3  
Old March 3rd, 2002, 07:24 PM
kreyes kreyes is offline
dark angel
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Location: in your mind....
Posts: 2 kreyes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
ive already tried fixin the errors ......already fixed but how come it generateda segmentation fault whats worng with my code or what might have possibly caused it?

Reply With Quote
  #4  
Old March 4th, 2002, 04:46 AM
WoR WoR is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Posts: 23 WoR User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
segmentation fault seams to indicate that you're accessing data you shouldn't. This points to either pointers or indices.

In your 3.lvl while - loop
while(pTemp->sGame.strQuestions[i]!='\0')
you don't increment 'i' so you got an infinite loop. I don't really understand your code so i can't tell you what the correct version should look like.

Hope it helps

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > whats this warning mean?and how to search keyword...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway