I don't understand why you try to make thing complicated.
check it here strstr - C++ Reference
However, if you're required to find the occurrence of a string in another one, you should better consider Knuth Morris Pratt algorithm what he said above.
In your previous code, I found something...
User Profile
Collapse
-
Try this :
1. int y;
2. void square(int x, int *result)
3. {
4. *result = x*x;
5. }
6. ...
7. square(3, &y);Leave a comment:
-
malloc is used to allocating memory and return a (void *).
You should return a pointer of type struct list from malloc.
so
[code=c]
struct list *s = (struct list *)malloc(sizeof (struct list));
[/code]...Leave a comment:
-
Kernel programming, i think, is what you need. With kernel programming, everything is in your hands even your OS. You can do whatever you want. but it is more dangerious, if you have made the mistake even the smallest one, you can bring BSD ( blue screen of death ). Microsoft has released the DDK version 6.0.0.x, the lastest version of DDK supported up to Vista.
I would recommend if you really want to access the real devices on system, you...Leave a comment:
-
You all right!... The last condition must be if ((move_main==9) && (score_main[i]!=3) && (score_main[i]!=-3)).
In your code above, you have 4 loops. In the two above, you check for score_main[i] value, the last 2 more, you check for score_main[i] and move_main.
All the four loops are used to assigned the value to variable result. This is the point.
Check yoru design again, If the condition has already been true...Leave a comment:
-
I would like you to review your design first before we are going to choose the appropriate detail design:
You have 3 arrays of int, each of which is sized 650000
so how much memory the program will allocate for you when you run this snippet of code : (3 * 32 * 650000)/(8 * 1024 * 1024 ) = 7.4 GB
Do you really think you have 7.4 GB of RAM in your machine ?
And only your program runs at the time ? it is impossible right...Leave a comment:
-
The code above is not yet completed, as what you said.
I would say something about your code above:
- You should learn how to use the header file of your project. It is more useful when your code become the library for other to call.
- Define error messages for all of the possible states and bugs
- Never use the number in your C file. it is hard to update your code again when there is a new update on the requirement....Leave a comment:
-
iptables : ipt_time : invalid size 16 != 24
Hello everyone!, I currently have debian box
I want to patch iptables to support time match with the latest version of kernel 2.6.24.2 ( at the time of writing ).
I download
- Kernel 2.6.24.2
- Iptables 1.4.0
- p-o-m
steps
- patched iptables and kernel
- re compile the kernel
- reboot the system
- make & make install the iptables 1.4.0
I have thrown the command... -
Eclipse for C++ is only the editor for C++, but it is more like a plateform rather than an editor, because you can add or remove many modules from Eclipse.
So if you want to have your C++ code run on Elipse, you need to have a compiler installed on your machine first. If you are using the last release of Eclipse ( i am not sure which version ). It automatically detect a compiler on your stystem. For previouse verison, you need to point to...Leave a comment:
-
Hm.....that is a one more idea of you RRick.
The user input is always untrusted. You can't assume that user always input integer or whatever you expected. So A good way to handle it is to assign all the input data from user into string.
Do you think it is possible when you declare int x; then user input alpha data. It sounds so funny right ?...Leave a comment:
-
Well, that is a good catch guy!
Code:int age ....... ...... cin >> age;
The solution is to declare age as
Code:....................................... ....................................... #define MAX_INPUTS_LENGTH
Leave a comment:
-
Well this is the new algorithm, you can go with
<Code removed - please read our Posting Guidelines>...Leave a comment:
-
Well let me break your source codes in pieces and go line by line.
This block of code should be in a header file.....why ?
I do know that it works just the same way as what you did it now, but you will have some big problems in upgradability and scalability. so why ?
What happen when another file .cpp want to call a routine in this prototype ?
or what if your code becomes a Library for the all...Leave a comment:
-
The algorithm is simple:
First of all, you need to know what is the difference between
- even number ( 2, 4, 6, 8...etc )
- odd number ( 1, 3, 5, 7....etc )
{2, 4, 6, 8...etc} divided by 2. The rest number will be Zero
{1, 3, 5, 7....etc} divided by 2. The rest number will be One
The operator you can use to calculate the the rest number from division is modulo ( % ).
Example:
4 % 2 =...Leave a comment:
-
I don't cover much in how to read this file and extract the info into your structure! but i wanna look at your structure and give some comments instead.
I would suggest that you write down something like this
Code:#define MAX_NAME_LENGTH (10) #define MAX_SURNAME_LENGTH (15)
In fact, there is no difference between this one and your code but is...Leave a comment:
-
Well, let review your code again, as long as i know therer are many problems possible happens with this piece of code:
- line 9:
When N is null, you just call to CreateNode() in order to allocate and initialize your N right ?
I do believe that you assume that this CreateNode work properly as what you expected because you are author of this code. I believe that in your CreateNode(), you have allocated memory and initialize...Leave a comment:
-
Let review your algorithm first before we get on the new way!.
Your structure size is 40 bytes.
Your table is [3000][3000]
Total you confume 40 * 3000 * 3000 = 360, 000, 000 bytes = 343 MB
Imagine! your application just only launch then it allocates 342 MB in Memory! it must and you deserve a buffer over flow!.
becausse array is automatically allocated in memory when we declare it by defining it size. Furthermore,...Leave a comment:
-
Well, in fact there are a few technic to do that
- If you are using an IDE such as Visual Studio, you can set break point on where you want to pause the execution ( press F9 ). then you just click start debugging.
- If you are using a command based compiler such as Mingw, you can call getchar() in stdio.h in order to pause the execution.
This is the example
[code=cpp]
#include <stdio.h>
int...Leave a comment:
No activity results to display
Show More
Leave a comment: