C - 2 conditions in if statements [closed] - c

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 8 years ago.
Improve this question
hope you have a solution for me, here my matter:
if (!strcmp(bgcolor,"RED")&& (ekey & keyup) {*strncpy(bgcolor,"GREY",5);}
How can i execute this in the right way?
Edit: Thanks, newbie here,
Edit: ehm... what about this?
if (ekey & keyB && (ekey & keyup && (!strcmp(bgcolor,"RED")))) {*strncpy(bgcolor,"GREY",5);}

You have a syntax error in your snippet, more specifcally the parentheses are not matched properly (you are missing the closing paren surrounding the if-condition).
You are probably looking for something as:
if (!strcmp (bgcolor, "RED") && (ekey & keyup)) {
strncpy (bgcolor, "GREY", 5);
}
Note: Notice the )) after keyup...

Try this
if (!strcmp(bgcolor,"RED") && (ekey & keyup))
{
strncpy(bgcolor,"GREY",5);
}

Related

Swift .sorted(by:) returns the incorrect type [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 8 months ago.
Improve this question
I have an array of type [String: MyCustomStruct] that's being decoded from a response by the server. I'm then just trying to sort the array on the client side based on a value in the custom struct. For some reason, I'm getting an error:
'Cannot assign value of type '[Dictionary<String, MyCustomStruct>.Element]' (aka 'Array<(key: String, value: MyCustomStruct)>') to type '[String : MyCustomStruct]''
My code looks like this:
do {
decodedArray = try JSONDecoder().decode([String: MyCustomStruct].self, from: jsonData)
print("DECODING PROCESS SUCCESS: \(decodedArray)")
} catch {
print("DECODING PROCESS FAILED: \(error)")
}
DispatchQueue.main.async {
self.places = decodedArray.sorted(by: { $0.value.rating > $1.value.rating })
}
Why is this getting a type error? The type of 'self.places' is also defined as [String: MyCustomStruct]...
[String: MyCustomStruct] is not an Array. It's a Dictionary. That is very important here. You're not decoding an Array. Sorting a Dictionary probably does not mean what you expect. The Dictionary.sorted(by:) function returns an Array of Elements, which is what you're seeing here.
I expect self.places is of the wrong type. It should be [MyCustomStruct] given the code you've written. If you're trying to create an ordered dictionary, see OrderedDictionary in the swift-collections package.

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.

How to get the Query values? [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 7 years ago.
Improve this question
SqlDatasource1 :
Table1
-----------
Result_1
-----------
Result_2
I have a query, and I want to get a Result_2 value from the query in code behind, in the BeforePrint event, and I don´t want to put a label in the report, how can I do this?
Thanks
If you want to manually run the Select command on your data source, you could try something like (C#):
var dv = new DataView()
dv = Sqldatasource1.Select(DataSourceSelectArguements.Empty) as DataView;
if (dv.Count > 0)
{
foreach (DataRowView rv in dv)
{
string Result2Val = rv["Result_2"].ToString();
// do something with the result...
}
}
I'm sure VB will follow a similar pattern.
Alternatively, try and capture the OnSelected event, if it's already being triggered by another control.

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

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

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