Can I use while(strstr(name[a],sname)!=NULL) [closed] - c

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I'm writing a phonebook application and one of the functions is for searching the phonebook by name.
The program should print out the names the same way as the user entered them (later I will include the numbers and other info). The phonebook has 100 contacts.
sname is the name that user have entered to search.
name[a] is name list. Is there any other code like strstr? Like its operating if its found printing them if not then print("not found any") something like this:
for(a=1; a<101; a++) {
while(strstr(name[a],sname) != NULL) {
printf(strstr(name[a], sname));
}
}

You can do that: it is an infinite loop.
while(strstr(name[a],sname)!=NULL){
printf("%s\n",strstr(name[a],sname));
}
None of a, name[a], sname change in the conditions or body of the while

Related

Unable to create database in Codeql [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 days ago.
Improve this question
I'm trying to create a database in Codeql but I'm unable to do it.
My input project is a simple hello.c in "/home/puya/Desktop/test" directory, and its source code is:
#include<stdio.h>
int main(void) {
printf("HELLO World!");
return 0;
}
and my command to create database is:
./codeql database create /home/puya/Desktop/database --language=cpp --source-root /home/puya/Desktop/test
and the output is:
enter image description here
enter image description here
Can anyone help me?

How to use variables in django url path? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am developing and Django website, and I have an array of some str values(parts of url).When user is redirect to:
https://www.example.com/something/name/
how can system system knows that that is part of that arry.
I alredy have this:
urlpatterns = [
path(r'<name1>, views.example')
]
And Array:
arr = [name1,name2,name3, ....namen] # elements of array are assigned to variables in for loop.
Thank you in advance.
So you need to change urlpatterns to:
path('<str:name>,views.example)
str is data type, and other data type for this use are:
int – Matches zero or any positive integer.
str – Matches any non-empty string, excluding the path separator(‘/’).
slug – Matches any slug string, i.e. a string consisting of alphabets, digits, hyphen and under score.
uuid – Matches a UUID(universal unique identifier).
And function call to:
views.example(request, name = "name_n") # for better code reading use name_1, name_2, .. name_n instead of name1,name2 etc.
and that would be it, enjoy in Django.

request for member 'nama' in something not a structure or union [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
so i have this code, but when im running it, it's shows that "error : request for member 'nama' in something not a structure or union.
this is an admin program when you buy a movie ticket, and the modul need the name of the admin to print it in the ticket
struct admin
{
char nama[100];
char id[100];
char password[100];
};
struct admin pengatur[100];
ModeAdmin(pengatur[counter]);
void ModeAdmin(struct admin *c)
{
struct admin pembuka;
strcpy(pembuka.nama,c.nama);
strcpy(pembuka.id,c.id);
strcpy(pembuka.password,c.password);
printf("Welcome %s",pembuka.nama);
printf("1. Print Ticket\n");
printf("2. Add New Film\n");
}
This:
c.nama
should be:
c->nama
since c is not a struct or union, it's a pointer to a struct.
c is a pointer to a struct, not a struct itself, so you can't use the . operator on it. You need to instead use ->, which dereferences the pointer and then gets the member:
strcpy(pembuka.nama,c->nama);
strcpy(pembuka.id,c->id);
strcpy(pembuka.password,c->password);
Change
strcpy(pembuka.nama,c.nama);
to
strcpy(pembuka.nama,c->nama);
And all other occurences of c. likewise.
It is necessary because while pembuka is of type struct admin, c is only a pointer to one.

Data structure: Circular Queue (in C) [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I'm doing a Uno Card game (in C) and I have a Circular Queue in this following order:
user -> player1 -> player2 -> player3
If any player put in the table a card that change the order of the game, would be in the opposite direction.
For example, if the user put the "reverse" card, I would have to dequeue every player and the, enqueue like that:
enqueue(player3);
enqueue(player2);
enqueue(player1);
enqueue(user);
If player1, dequeue everybody and then:
enqueue(user);
enqueue(player3);
enqueue(player2);
enqueue(player1);
If player2, dequeue everybody and then:
enqueue(player1);
enqueue(user);
enqueue(player3);
enqueue(player2);
If player3, dequeue everybody and then:
enqueue(player2);
enqueue(player1);
enqueue(user);
enqueue(player3);
It's terrible, isn't it? Put it in this way, like, one "if" to any case. I know that when someone put the "reverse" card the first thing to do is to dequeue everybody, but after that, is there a better way to enqueue following the thought above?
Could you not do this with a simple index and a step (+1 or -1)?
index = { player1, player2, player3, user }
step = { clockwise, anticlockwise}
When a reverse card is played, just change the sign of the step?
Start: index=player1, step=clockwise(+1)
Repeat
Player plays card... if reverse, step = !step
Move to next player: index += step
Until end
Obviously, index needs bounds checking etc, but you get the principal

Stop word removal in Javascript [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
HI I am looking for a library that'll remove stop words from text in Javascript, my end goal is to calculate tf-idf and then convert the given document into vector space, and all of this is Javascript.
Can anyone point me to a library that'll help me do that.Just a library to remove the stop words would also be great.
Use the stopwords provided by the NLTK library:
stopwords = ['i','me','my','myself','we','our','ours','ourselves','you','your','yours','yourself','yourselves','he','him','his','himself','she','her','hers','herself','it','its','itself','they','them','their','theirs','themselves','what','which','who','whom','this','that','these','those','am','is','are','was','were','be','been','being','have','has','had','having','do','does','did','doing','a','an','the','and','but','if','or','because','as','until','while','of','at','by','for','with','about','against','between','into','through','during','before','after','above','below','to','from','up','down','in','out','on','off','over','under','again','further','then','once','here','there','when','where','why','how','all','any','both','each','few','more','most','other','some','such','no','nor','not','only','own','same','so','than','too','very','s','t','can','will','just','don','should','now']
Then simply pass your string into the following function:
function remove_stopwords(str) {
res = []
words = str.split(' ')
for(i=0;i<words.length;i++) {
word_clean = words[i].split(".").join("")
if(!stopwords.includes(word_clean)) {
res.push(word_clean)
}
}
return(res.join(' '))
}
Example:
remove_stopwords("I will go to the place where there are things for me.")
Result:
I go place things
Just add any words to your NLTK array that aren't covered already.
I think there are no libraries for such thing, you need to download those words from https://www.ranks.nl/stopwords.
And then do replace the words as follows:
text = text.replace(stopword, "")
Here's an array with english stopwords. Hope it helps. From http://www.ranks.nl/stopwords (mentioned in previous answer).
Also, this could be a helpful resource for you.
https://github.com/shiffman/A2Z-F16/tree/gh-pages/week5-analysis
http://shiffman.net/a2z/text-analysis/
var stopwords = ["a", "about", "above", "after", "again", "against", "all", "am", "an", "and", "any","are","aren't","as","at","be","because","been","before","being","below","between","both","but","by","can't","cannot","could","couldn't","did","didn't","do","does","doesn't","doing","don't","down","during","each","few","for","from","further","had","hadn't","has","hasn't","have","haven't","having","he","he'd","he'll","he's","her","here","here's","hers","herself","him","himself","his","how","how's","i","i'd","i'll","i'm","i've","if","in","into","is","isn't","it","it's","its","itself","let's","me","more","most","mustn't","my","myself","no","nor","not","of","off","on","once","only","or","other","ought","our","ours","ourselves","out","over","own","same","shan't","she","she'd","she'll","she's","should","shouldn't","so","some","such","than","that","that's","the","their","theirs","them","themselves","then","there","there's","these","they","they'd","they'll","they're","they've","this","those","through","to","too","under","until","up","very","was","wasn't","we","we'd","we'll","we're","we've","were","weren't","what","what's","when","when's","where","where's","which","while","who","who's","whom","why","why's","with","won't","would","wouldn't","you","you'd","you'll","you're","you've","your","yours","yourself","yourselves"];
There's a Javascript Library for removing stopwords here: http://geeklad.com/remove-stop-words-in-javascript

Resources